$line=~/.*\sid=\"(.*)\"\slo=\"(.*)\"\sto=\"(.*)\"\srb=.*$/; #### #maybe try something like print "$2\n\n" if $2; ####