in reply to Print 4 Lines below matching criteria
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Print 4 Lines below matching criteria
by johngg (Canon) on Nov 16, 2006 at 11:30 UTC | |
|
Re^2: Print 4 Lines below matching criteria
by Anonymous Monk on Nov 16, 2006 at 10:41 UTC |