Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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
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?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2015-10-07 00:48 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (166 votes), past polls