use strict; use warnings; my $para = 'This is a wilma line barney is on this line but this line ends with fred ** this line has barney in the middle ** and a final dino line'; my $count = 0; for my $line (split /\n/, $para) { printf "line %d: >%s< -- barney %sfound\n", ++$count, $line, $line =~ /^\s*barney/ ? '' : 'not '; } #### 13:49 >perl 1958_SoPW.pl line 1: >This is a wilma line< -- barney not found line 2: > barney is on this line< -- barney found line 3: > but this line ends with fred< -- barney not found line 4: > ** this line has barney in the middle **< -- barney not found line 5: > and a final dino line< -- barney not found 13:49 >