#!/usr/bin/perl -w my $string = ' Costly false alarms Mindless yobs terrorise OAPs Road deaths Twisted porn pervert caged for life Greenbelt homes plan appeal thrown out '; while ( $string =~ m!(]*>)(.+?]*>)!ig ) { print "1st match: $1 \n"; print "2nd match: $2 \n\n"; } #### 1st match: 2nd match: Costly false alarms 1st match: 2nd match: Mindless yobs terrorise OAPs 1st match: 2nd match: Road deaths 1st match: 2nd match: Twisted porn pervert caged for life 1st match: 2nd match: Greenbelt homes plan appeal thrown out