while(<>) { print join("\n", map { "$_ lineno $." } /(string)/g); }
On Friday, September 6, 2002, at 10:32 PM, Harry Putnam wrote: > Tinkering with some of the suggestions here, I was looking for a way > to get the line number in there. Thought maybe I could just > concatenate it in there: > > With this test file: > string strung strang string other junk > blabbitty string other junk > > while(<>){ > push @array,$_ =~ /(string)/g . " lineno " . $.; > } > > for(@array){ > print $_ . "\n"; > } > > Results: > 1 lineno 1 > 1 lineno 2 > > So it gives the line number alright but botched the ability to grab > the hits. > > Whats a sneaky way to get the linenumber where the hit occured? > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > // George Schlossnagle // Principal Consultant // OmniTI, Inc http://www.omniti.com // (c) 240.460.5234 (e) [EMAIL PROTECTED] // 1024D/1100A5A0 1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]