in reply to Matching for the second,fourth, and fifth word in a text
this ought do
while( defined my $record = <FILE> ) { if( $record =~ m/(?x) \A ## anchor the match to the beginning of the reco +rd printer \s+ ## match the word 'printer', and one or more spa +ces (?: \w+ \s+ ){2} ## match two words followed by spaces idle \. \s+ ## match the word 'idle', followed by a period a +nd spaces enabled \s+ ## match the word 'enabled', followed by spaces / ) { ## $record matched, do your thing... } }
~Particle *accelerates*
|
|---|