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 ( #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$..$/


Comment on Re: close ARGV inside a while
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2015-07-04 17:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls