Re: Can't open file.

2005-12-06 Thread David Sudjiman
On Tue, 6 Dec 2005, John W. Krahn wrote: > An array in scalar context returns the number of elements in the array so if > @ARGV contains one file name then $filename will be assigned the number 1. > You want to do either: > > my $filename = shift @ARGV; > > Or: > > my ( $filename ) = @ARGV; I

Re: Can't open file.

2005-12-06 Thread Mohammed Shameer
> my $filename = @ARGV; you are assigning an array ( list ) to a scalar. so the rvalue will be calculated in scalar context which will be the number elements in @ARRAY which will be 1 if you give one argument (my $filename) = @ARGV; On Wednesday 07 December 2005 05:40, David Sudjiman wrote:

Re: Can't open file.

2005-12-06 Thread John W. Krahn
David Sudjiman wrote: > Hi All, Hello, > I try this script: > > #!/usr/bin/perl > > use strict; > use warnings; > > my $filename = @ARGV; An array in scalar context returns the number of elements in the array so if @ARGV contains one file name then $filename will be assigned the number 1. You

Can't open file.

2005-12-06 Thread David Sudjiman
Hi All, I try this script: #!/usr/bin/perl use strict; use warnings; my $filename = @ARGV; my $lines; #open FILE, "fred.txt" or die "Can't open foobar.txt : $!"; open FILE, $filename or die "Can't open $filename : $!"; $lines = join '', ; print "$lines\n\n\n\n"; $lines =~ s/^/fred.txt: /mg;