Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Re: strict

by snowrider (Pilgrim)
on Feb 02, 2001 at 01:42 UTC ( [id://55853]=note: print w/replies, xml ) Need Help??


in reply to Re: strict
in thread strict

i can make the program work when i use
my $line; my @lines;
but i cant seem to make
#!/opt/perl5/bin/perl -w use strict; #my $line; my @lines; while(my $line=<> and $line ne ".\n"){ push @lines,$line; } foreach(reverse @lines){ print; }
work am i doing something wrong?? i keep getting this error
Global symbol "$line" requires explicit package name at day1_test.1.pl + line 8. Value of <HANDLE> construct can be "0"; test with defined() at day1_te +st.1.pl line 8. Execution of day1_test.1.pl aborted due to compilation errors.
snowrider

Replies are listed 'Best First'.
Re: Re: Re: strict
by arturo (Vicar) on Feb 02, 2001 at 01:47 UTC

    Whoops. The problem is that the second way I gave you won't work because the my $line part of it will fail -- and the variable won't be declared -- if you read in a blank line from the file you're looking through. So you could get a loop with the same logic by changing it to:

    while (my $line = <> ) { push @lines, $line unless $line eq ".\n"; }

    HTH

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor

      thank you you have been a big help!! snowrider

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-25 21:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found