Reputation: 21
I have a logfile and there I am trying to store all the line once I found This has happened due to.
and then new line starts.
So basically the log looks like this
Bla bla bla bla....This has happened due to.
ABC
DEF
GHI
JKL
can you please help me to match the paatern once I found the line "This has happened due to."
Upvotes: 1
Views: 94
Reputation: 782653
while (<>) {
next unless /This has happened due to/;
while (<>) {
# Process lines
}
last;
}
Upvotes: 4
Reputation: 150178
#!/usr/bin/env perl
while (<>) {
last if /This has happened due to/;
}
while (<>) {
print; # do smth with the line
}
Save the script to a file and make it executable. Then run like ./script.pl logfile
Upvotes: 3