in reply to Re: Find If Value Exists In Array Of Hashes
in thread Find If Value Exists In Array Of Hashes

Thanks NetWallah for the questions. While getting sample data to answer them, I noticed there is a way to de-dup built right into the data stream lines (field 4, the "Y" in my sample, has to be "Y" -> if it's "N", it's a duplicate). If you wouldn't have asked for clarification, I never would have seen that!!

Thank you so much for leading me to a FAR simpler solution than I imagined!!!

  • Comment on Re^2: Find If Value Exists In Array Of Hashes

Replies are listed 'Best First'.
Re^3: Find If Value Exists In Array Of Hashes
by SirClive (Scribe) on Aug 12, 2014 at 08:52 UTC
    Instead of all of those if clauses to add leading zeroes to the date / time elements could you not just use sprintf ? (untested)
    my $stamp = sprintf '%02d/%02d/%02d.%02d.%02d.%02d', $year, $mon, $mday, $hour, $min, $sec
      It's a long time since I wrote any perl :( Correction
      use strict; use warnings; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); my $stamp = sprintf "%02d/%02d/%02d %02d.%02d.%02d", $year +1900, $mon +1 , $mday, $hour, $min, $sec; print STDOUT $stamp;
      Output 2014/08/12 10.24.56
        Ah yes - as I said it is a long time since I used perl and even longer since I used 'C' :) :) This is better
        use strict; use warnings; use POSIX qw(strftime); my $date = strftime("%Y/%m/%d %H:%M:%S\n", localtime(time)); print $date;
        Output 2014/08/12 10:36:29