in reply to Dynamically changing the value of a passed variable into a sub
Well ... first you pass in a parameter and then you modify a global variable?
Another problem is that you modify $_ without localizing it!
The $_ = $_[0]; made a copy of the parameter and you then modified the copy, not the parameter itself. You either want to work on the $_[0] directly or use
sub TimeStamp { for ($_[0]) { if( /(\d{4})(\d{2})(\d{2})/ ) { #returns in MMDDYYYY $_ = "$2/$3/$1" } else { warn "Invalid input to TimeStamp()"; } } } ... TimeStamp($date_created); # will modify $date_created
Jenda
|
|---|