in reply to Dynamically changing the value of a passed variable into a sub

While I agree with chromatic in that dirtying your parameters is a bad idea, here's another solution for completeness
sub TimeStamp($) # Pass the stamp in as YYYYMMDD { if( $_[0] =~ /(\d{4})(\d{2})(\d{2})/ ) { #returns in MMDDYYYY $_[0] = "$2/$3/$1"; } else { warn "Invalid input to TimeStamp()" } }
This will change the variable that is passed to it as the @_ variable is really just a list of aliases (see. rinceWind's node for more info on the magicality of @_).
HTH

_________
broquaint

  • Comment on Re: Dynamically changing the value of a passed variable into a sub
  • Download Code