foreach my $lines (@lines){ if( $lines =~ /(.*?)<\/u>/igs ){ print "\n $1\n"; } }