Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: strict

by athomason (Curate)
on Feb 02, 2001 at 01:34 UTC ( [id://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; }

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://55847]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-24 22:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found