if (m#([^\|]+)\|([^\|]+)$#) { $a=$1; $b=$1; } else { chomp; die "Bad line: $_\n"; } #### ($a,$b,$c) = m/(your)(regex)(here)/;