$line =~ /^( # start $1 \D+ # unit ind. (US$ for ex) \d+(?:\.\d+)? # the amount \s+ # whitespace [A-Z]+ # scale (mil for ex) ) # end $1 (.+) # $2 - the second part \sdue\s # literal word 'due' surrounded by spaces (.+) # $3 $/xi; my @columns = ($1, $2, $3)