/^\.(\w+).*$\t+\.\w+\W+(\w+).*$/m #### .somewords any amount of garbage till a suposed end of line [some number of tabs].nomatchwords matchedwords garbage to eol #### #!/usr/local/bin/perl -w use strict; $|++; $/="\n."; while ( ) { print join ' ', /^\.?(\w+).+\n\t+\.\w+\W+(\w+)/; print "\n"; } __DATA__ .this is a line .and this is another line .again, a line. .Yet another line