$retid =~ /\A(\d{4})(_\d{3})?\z/ or die "Malformed ret. id\n"; my $new_retid = $1 . ( $2 ? $2 : '_001' ); #### $retid .= '_001' if not $2;