Reputation: 1529
I need to process a log file. I send it to Perl via <STDIN>
. I need to output only the summary, which follows a line that contains several equal signs.
The summary is the last bit in the daily log. So, I need everything starting after the line with the =
s through EOF.
I tried using a while
loop with a "next unless
" but I could not get that to work.
Upvotes: 0
Views: 118
Reputation: 385655
You need a flag or two loops.
Includes the trigger line in the output:
perl -e'
while (<>) {
last if /===/;
}
if (defined($_)) {
print;
while (<>) {
print;
}
}
' log
perl -ne'print if $print ||= /===/' log
Doesn't include the trigger line in the output:
perl -e'
while (<>) {
last if /===/;
}
if (defined($_)) {
while (<>) {
print;
}
}
' log
perl -ne'last if /===/; END { print while <> }' log
perl -ne'print if $print; $print ||= /===/' log
perl -ne'print unless 1 .. /===/' log
Upvotes: 4