$_ = 'ab$=$12a3$=$45$=$4thfield$=$5th'; ( $a, undef , $b ) = $_ =~ /(\w+)\$=\$(\w+)\$=\$(\w+)/; print "=>$a<==>$b<=\n";