Try:
$Variables[$X]=$Year."-".$Months{$Month} ."-" . $Day ;
Also see sprintf for formatting text strings (e.g.: $Day = sprintf('%02d', $Day);)
But really you should avoid manipulating dates by hand. There are plenty of modules that do it better, faster and more safely. See for example DateTime::Format::Strptime. This will give you a tool to read in a date using whatever format you have it in, transform it in some way if desired, and print it out again in a different format. For example:
Output:use strict; use warnings; use feature 'say'; use DateTime::Format::Strptime; my $date = 'Apr 23 2017 11:56:42'; my $parser = DateTime::Format::Strptime->new( pattern => '%b %d %Y %T' +, on_error => 'croak' ); my $dt = $parser->parse_datetime( $date ); say $dt->strftime('%F');
2017-04-23
Hope this helps!
Update: Added DT and sprintf examples
In reply to Re: Array of variables
by 1nickt
in thread Array of variables
by Michael W
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |