pidloop has asked for the wisdom of the Perl Monks concerning the following question:
Oh great Monks, I have a simple (I think) question of understanding.
I want to read a file until I find a line containing a pattern. I tried this:
but it complained about $_ undefined in m// match. So I then made the assignment to $_ explicit like so and it works great:while (<> and !/pattern/) {}
I am surprised by the need of doing this and would like to understand why. Thank you all!while (defined($_ = <>) and !/pattern) {}
Back to
Seekers of Perl Wisdom