Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hello Bill, Thanks for helping me but i have the issue with multiple entries of the dates for different key. I have following data structure in my hash but i will need only one entry for the date and time which is more recent among all the respective keys and values but i am 2 values - one min and maximum. I will need one value instead. How i can achive?

My expectation should be below

ID: 900000001, Net Cat : NETOWORK2 , Valid: 2021-03-10T18:15:54.000Z ID: ID: 566000003, Net Cat : NETOWORK2 , Valid: 2021-03-10T18:15:54.000Z ID: 266000003, Net Cat : Network1 ENV , Valid: 2021-03-08T13:34:59.000Z
my %hash = $VAR1 = { '900000001' => { 'Network1' => [ 'Not used', 'Not used', 'Not used', 'Not used' ], 'Network1 ENV' => [ '2020-09-09T18:36:5 +0.000Z', '2020-09-09T18:36:5 +0.000Z' ], 'NETOWORK2' => [ '2021-03-10T18:15:54.000 +Z', '2020-12-17T19:36:21.000 +Z', '2021-03-10T18:15:54.000 +Z' ] }, '266000003' => { 'Network1 ENV' => [ '2021-03-08T13:34:5 +9.000Z' ] }, '566000003' => { 'Network1 ENV' => [ '2020-09-09T18:36:5 +0.000Z', '2020-09-09T18:36:5 +0.000Z', '2020-09-09T18:36:5 +0.000Z' ], 'NETOWORK2' => [ '2020-12-17T19:36:21.000 +Z', '2020-12-17T19:36:21.000 +Z', '2020-12-17T19:36:21.000 +Z', '2020-12-17T19:36:21.000 +Z', '2020-12-17T19:36:21.000 +Z', '2020-12-17T19:36:21.000 +Z', '2020-12-17T19:36:21.000 +Z', '2020-12-17T19:36:21.000 +Z', '2021-03-10T18:15:54.000 +Z', '2021-03-10T18:15:54.000 +Z', '2020-12-17T19:36:21.000 +Z', '2021-03-10T18:15:54.000 +Z' ], 'Network1' => [ 'Not used', 'Not used' ] } };

my code snippet below in order to find most recent date for the user among all the keys

foreach my $key (keys(%hash)) { foreach my net (keys %{ $hash{$key} }) { my $date_time = (sort @{ $ssoidmfadates{$key}{$net} })[-1]; my @dt_dob1 = unpack("A4xA2xA2",$date_time); if (check_date(@dt_dob1)){ print "SSO ID: $key, Mfa Cat : $net , Valid: $date_time\n +"; } else { print "Not used"; } } }

In reply to Re^6: How i can create hash of arrays of hashes from my 3 arrays? by chandantul
in thread How i can create hash of arrays of hashes from my 3 arrays? by chandantul

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 12:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found