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
> 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:
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
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;