Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: strict

by athomason (Curate)
on Feb 02, 2001 at 01:34 UTC ( #55847=note: print w/ replies, xml ) Need Help??


in reply to strict

It's great you're using use strict and have warnings enabled; otherwise perl would never warn you about errors like this. The problem you're encountering is that when strict is enabled, perl requires that you declare your variables ($line and @lines, here) before using them. The simplest way is with the my keyword. Check out that link for more info. Other ways to declare variables include use vars and local, though my is the usual method for situations like yours. A quick fix might go like this:

#!/opt/perl5/bin/perl -w use strict; my ($line, @lines); while($line=<> and $line ne ".\n"){ push @lines,$line; } foreach(reverse @lines){ print; }


Comment on Re: strict
Select or Download Code
Re: Re: strict
by snowrider (Pilgrim) on Feb 02, 2001 at 01:49 UTC
    thanks for your help you just taught me that i can declare multiple variables at once. and that when you use strict you MUST declare your variables snowrider

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://55847]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2014-12-27 00:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls