or download this
if ($array[$line] =~ /0?.*?(RECORD .*)/){
$record = trim($1); # works correctly
...
$date = trim($1); # when no date it's using the previous $1 that
+ goes into $id
$address = trim($2); # when no date it's using the previous $2 that
+ goes into $name
... code continues ...