in reply to Re: Conditional continued matching with regexes
in thread Conditional continued matching with regexes
BTW, there's a syntax for tr that serves to just count occurrences, without changing anything. Just leave the RHS empty, which is like replacing characters by themselves while counting, but which is optimizined to skip the replacing.
tr/"//
You still need to cater for the abnormal case where the file contains an odd number of quotes, thus, check for eof.
Update Judging by the tests I've done, the next snippet will work excellently for reading and processing data from <>, and includes processing for the final record for each file, even if incomplete:
while(<>) { while(!eof and tr/"// % 2) { $_ .= <>; } # ... do stuff with each record in $_ }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Conditional continued matching with regexes
by dah (Sexton) on Feb 07, 2007 at 08:13 UTC | |
by MajingaZ (Beadle) on Feb 07, 2007 at 13:46 UTC |