in reply to Array of variables

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:

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');
Output:
2017-04-23

Hope this helps!

Update: Added DT and sprintf examples


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: Array of variables
by Michael W (Initiate) on Apr 27, 2017 at 16:09 UTC

    i tried that technique previously didn't work

    Step 1: load variables from sql call from database

    Step 2: placed variable into an array

    Step 3: process data in current array, formatting date to html date field format

    Step 4: reload the new back back into the variable that is in the array

    issue do not know how to address an array of variable to place the data back into the array variable

    $Variables$X = ( $Map_Request_Date,$Map_Due_Date,$Map_Cutover_Date,$Map_Complete_Date,$Map_Approved_Date);

      Nope, as choroba said in the chatterbox:

      @Variables = ( $Map_Request_Date, $Map_Due_Date, $Map_Cutover_Date, $M +ap_Complete_Date, $Map_Approved_Date );

      But again, this is no way to accomplish your task.

      Also, please use <code></code> tags for even the shortest code snippets: as you can see, in both your posts the square brackets used to denote array indices are not showing. This is because the posting engine treats them as something else because they are not in code tags.



      The way forward always starts with a minimal test.