in reply to Variable assignment confusion

I'd throw in some stricter error checking and write it like this:
$retid =~ /\A(\d{4})(_\d{3})?\z/ or die "Malformed ret. id\n"; my $new_retid = $1 . ( $2 ? $2 : '_001' );
Though unless you need it, I'd just change with the original value:
$retid .= '_001' if not $2;
Update: s/\Q\d{4}/(\\d{4})/ of course. Thanks catching this to Not_a_Number.

Makeshifts last the longest.