in reply to How to extract Start .. End from multiline file
Your code, shown below, does not work the same way. {update: proven wrong below, but I still wouldn't use it}while (<fh>) { ... } while (defined ($_ = <fh>)) { ... }
Also, the .. operator can't be used in the way you're working on your latter example. It needs to go between two complete expressions that will be evaluated for the range flipflop. You wrote:while ($var = <fh>) { ... }
You meant:if ($line =~ m/$stag/ .. /$etag/)
Perl thought you meant:if (($line =~ m/$stag/) .. ($line =~ m/$etag/))
See it? You never assigned to $_ so it never got the end condition.if (($line =~ m/$stag/) .. ($_ =~ m/$etag/))
--
[ e d @ h a l l e y . c c ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to extract Start .. End from multiline file
by revdiablo (Prior) on Sep 28, 2005 at 18:00 UTC | |
|
Re^2: How to extract Start .. End from multiline file
by ikegami (Patriarch) on Sep 28, 2005 at 18:19 UTC | |
|
Re: How to extract Start .. End from multiline file
by gasho (Beadle) on Sep 28, 2005 at 18:46 UTC |