in reply to Array of variables

Note: This was an accidental reply to "Array of variables" which was originally posted in April 2017. It was suggested by ++jdporter that I consider it for re-parenting.

[See "Re^5: Array of variables" for an explanation of the striking of the "Note:".]

G'day Michael W,

To my mind, the following is cleaner, more readable, and more maintainable. Here's the basic changes:

#!/usr/bin/env perl use strict; use warnings; my %months; @months{qw{Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec}} = '01' .. '12'; my $out_fmt = '%4d-%s-%02d'; my ($Map_Request_Date, $Map_Due_Date, $Map_Cutover_Date, $Map_Complete_Date, $Map_Approved_Date ) = ( 'Jan 1 2017 12:00', 'Jan 31 2017 12:00', 'Feb 28 2017 23:59', 'Mar 1 2017 12:01', 'Dec 31 1999 0:01' ); my @var_refs = \( $Map_Request_Date, $Map_Due_Date, $Map_Cutover_Date, $Map_Complete_Date, $Map_Approved_Date ); print "$$_\n" for @var_refs; for (@var_refs) { my ($m, $d, $y, undef) = split ' ', $$_; $$_ = sprintf $out_fmt, $y, $months{$m}, $d; } print "$$_\n" for @var_refs;

Output:

Jan 1 2017 12:00 Jan 31 2017 12:00 Feb 28 2017 23:59 Mar 1 2017 12:01 Dec 31 1999 0:01 2017-01-01 2017-01-31 2017-02-28 2017-03-01 1999-12-31

Update: It looks like I mis-clicked on your last post instead of your current post, and replied to that. Hopefully, there's still some useful information. [See "Re^5: Array of variables" for some more details about that.]

— Ken

Replies are listed 'Best First'.
Re^2: Array of variables
by jdporter (Paladin) on Dec 14, 2021 at 23:30 UTC

    For future reference: You can simply consider the node for re-parenting.

      Thanks and done. I changed the title slightly and added a note about where it came from: I hope that's sufficient.

      — Ken

        To be clear: I didn't suggest reparenting this post, mainly because it already has replies which allude explicitly to its necropostness.
        Also, you implied that you meant it to be a reply to a different node:

        It looks like I mis-clicked on your last post instead of your current post, and replied to that.
        But then you considered it to be promoted to root post:
        Please reparent (with all replies in this subthread) as a top-level SoPW post.

        That's not reparenting. See What do Janitors do?

        In any case, if you know you made an error and want it to be fixed, just /msg gods and we'll fix it with minimal rigamarole.
        But I'm really not inclined to move a post in a way that makes its replies contextless and confusing.

        I reckon we are the only monastery ever to have a dungeon staffed with 16,000 zombies.
Re^2: Array of variables
by eyepopslikeamosquito (Archbishop) on Dec 14, 2021 at 22:20 UTC

      Serendipity is alive and kicking. :-)

      — Ken