use strict; use warnings; while (my $line = <DATA>) { if ($line =~ /^id:\d+/) { for (1 .. 4) { my $following = <DATA>; print $following; } } }
prints:__END__ John, Doe Michael id:1234567890123 library:ACME City, state:PUEBLO, CO Phone:719-555-555 Street:1610 Sorrow AVE APT D Zip: 81004 Shakespeare, William id:4567890123999 library:Fisher Fine Arts Library City, state:Philadelphia, PA Phone:215-898-8325 Street:Locust Zip: 19104
City, state:PUEBLO, CO Phone:719-555-555 Street:1610 Sorrow AVE APT D Zip: 81004 City, state:Philadelphia, PA Phone:215-898-8325 Street:Locust Zip: 19104
Update: Sorry, jbert, your post was not on yet when I started.
In reply to Re: Print 4 Lines below matching criteria
by fenLisesi
in thread Print 4 Lines below matching criteria
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |