in reply to Variable assignment confusion
Use a function to wrap it, so that it can be reused:
print foo("1234"), "\n"; print foo("1234_002"); sub foo { return ($_[0] =~ /^\d{4}$/) ? $_[0] . "_001" : $_[0]; } [download]