use strict; use warnings; my $FORMAT="%-48s match=%s\n"; while (my $line = ) { chomp $line; my $bFound=0; while ($line =~ m{"/([^"]+)"|/(\S+)}g) { my $sMatch = defined($1) ? $1 : $2; print sprintf($FORMAT, "<$line>", "<$sMatch>"); $bFound=1; } print sprintf($FORMAT, "<$line>", "---") unless $bFound; } __DATA__ "/moreIters 10" "/blah X Y Z" /fewIter /some stuff here "/albatross" foo bar baz monkeys leprechauns /not monkeys /gnomes "not leprechauns though" /grumpy gnomes "/silly elves" "/funny" fairies