Reputation: 221
I am learning how to use Perl and I am trying out different approaches. I know this is wrong, but I need to know why and how I can use a similar approach to assigning lexical variables. Your assistance would be greatly appreciated.
#Set vars
my (
$TIMESTAMP = strftime("%Y%M%d%H%M%S", localtime),
$SourceDir = 'C:\Documents\Source_Dir',
$destinationDir = 'C:\Documents\$website'
);
Upvotes: 1
Views: 100
Reputation: 132858
Use a list assignment with all the variables on the left on the assignment operator and all of the values on the right:
my( $TIMESTAMP, $SourceDir, $destinationDir ) = (
strftime("%Y%M%d%H%M%S", localtime),
'C:\Documents\Source_Dir',
'C:\Documents\$website'
);
Or, do them one by one.
Upvotes: 3