On Sat, Mar 3, 2012 at 9:08 AM, lina <lina.lastn...@gmail.com> wrote:
> $ perl extract.pl try.tex
> Bareword "filename" not allowed while "strict subs" in use at extract.pl line 
> 8.
> Execution of extract.pl aborted due to compilation errors.
>
>
> #!/usr/bin/env perl
>
> use strict;
> use warnings;
>
> my $filename = $ARGV[0] ;
>

You used 'filename', not '$filename'
'filename' is a bareword - not a perl variable, or a string.

> open FILE, "<", filename or die $!;
>
> my @line = <FILE> ;
>

You just read the entire file into the @line array.
If that is your intent, you need to loop on @lines.
Otherwise, if you wish to read the file line by line, omit the line
   my @line = <FILE>;

> while (<FILE>) {
>        print $_;
> }
>
>
> I tried mf $filename = <STDIN> also not work.
>
> Thanks ahead for any suggestions,
>
> Best regards,
>

HTH, Ken

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to