Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: close ARGV inside a while

by liverpole (Monsignor)
on Jun 08, 2006 at 13:17 UTC ( [id://554271]=note: print w/replies, xml ) Need Help??


in reply to close ARGV inside a while

Hello again, jesuashok,

I'm not sure why you think it's strange behaviour; it seems logical to me.

You are putting $0 (the name of the current file) into @ARGV, and then reading from that file.  When you close the file with close ARGV, you've already read one line, which is in $_.  So when you do:

print '.',$_;

you are simply printing out a period '.', concatenated with the first line of the Perl script itself.

Try taking out the line close ARGV; and the whole program will be printed:

#!/usr/bin/perl -w use strict; use warnings; #prints one line and bails out @ARGV = ( $0 ); while (<>) { # close ARGV; print $_; } # Output #!/usr/bin/perl -w use strict; use warnings; #prints one line and bails out @ARGV = ( $0 ); while (<>) { # close ARGV; print $_; }

s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-26 03:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found