Perl syntax
F. Duran
liberosec-FFYn/CNdgSA at public.gmane.org
Mon May 30 14:05:55 UTC 2005
declare the variables before using them:
my $count;
my $file;
etc
--- John Wildberger <wildberger-iRg7kjdsKiH3fQ9qLvQP4Q at public.gmane.org> wrote:
> In the recent thread on this subject the 'use
> strict' pragma was very strongly
> suggessted.
> Here is a very simple program urc2_1.pl:
>
> #! /usr/bin/perl -w
> use strict;
> while (<>){
> $count{$ARGV}++;
> }
> foreach $file (sort keys %count){
> print "$file has $count{$file} lines\n";
> }
>
> When executed it gives the following error messages:
>
> [john]: 09:46 AM [~/perl]
> $ ./urc2_1.pl urc2_1.pl
> Global symbol "%count" requires explicit package
> name at ./urc2_1.pl line 4.
> Global symbol "$file" requires explicit package name
> at ./urc2_1.pl line 6.
> Global symbol "%count" requires explicit package
> name at ./urc2_1.pl line 6.
> Global symbol "$file" requires explicit package name
> at ./urc2_1.pl line 7.
> Global symbol "%count" requires explicit package
> name at ./urc2_1.pl line 7.
> Global symbol "$file" requires explicit package name
> at ./urc2_1.pl line 7.
> Execution of ./urc2_1.pl aborted due to compilation
> errors.
>
> Without the 'use strict' pragma it executes without
> errors like this:
>
> [john]: 09:44 AM [~/perl]
> $ ./urc2_1.pl urc2_1.pl
> urc2_1.pl has 9 lines
>
> What changes to the program will I have to make to
> correct this?
> John
> --
> The Toronto Linux Users Group. Meetings:
> http://tlug.ss.org
> TLUG requests: Linux topics, No HTML, wrap text
> below 80 columns
> How to UNSUBSCRIBE:
> http://tlug.ss.org/subscribe.shtml
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list