in reply to Oddity...losing filename from stdin - very wierd
Why is that? A little deparse gives us the answer:
Should give us:perl -MO=Deparse -n -e 'print "file is: ".<>;'
So you see, every line of this loop, one filename is unshifted from ARGV going into $_, and one is unshifted and printed, making you miss the first, the third, etc.LINE: while (defined($_ = <ARGV>)) { print 'file is: ' . <ARGV>; }
What you need to do is something like
ls dir | perl -n -e 'print "File is $_"'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Oddity...losing filename from stdin - very wierd
by snafu (Chaplain) on Apr 09, 2002 at 17:01 UTC | |
by hossman (Prior) on Apr 09, 2002 at 23:22 UTC |