Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Unable to set the recent date from hash of array of hashes.

by choroba (Cardinal)
on Mar 16, 2021 at 11:59 UTC ( [id://11129754]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Unable to set the recent date from hash of array of hashes.
in thread Unable to set the recent date from hash of array of hashes.

Let's start simple. Do you know how to get the maximal date from an array?
my @dates = qw( 2020-12-17T19:36:21.000Z 2020-12-17T18:36:21.000Z 2021-03-10T18:15:54.000Z 2021-03-10T18:14:54.000Z 2020-12-17T19:36:29.000Z ); my $most_recent = ???; # <-- Fill in here.

OK, if that was simple, what about an array reference?

my $dates = [qw[ 2020-12-17T19:36:21.000Z 2020-12-17T18:36:21.000Z 2021-03-10T18:15:54.000Z 2021-03-10T18:14:54.000Z 2020-12-17T19:36:29.000Z ]]; my $most_recent = ???; # <-- Fill in here.

Now, let's try a hash of arrays:

my $dates = {date => [qw[ 2020-12-17T19:36:21.000Z 2020-12-17T18:36:21.000Z 2021-03-10T18:15:54.000Z 2021-03-10T18:14:54.000Z 2020-12-17T19:36:29.000Z ]]}; my $most_recent = ???; # <-- Fill in here.

Proceed in smaller steps.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^4: Unable to set the recent date from hash of array of hashes.
by chandantul (Scribe) on Mar 16, 2021 at 16:20 UTC

    Thanks Sir I was able to get the recent date but i am getting inconsistent network category against my users and date. Can you please let me know the solution here?

    Please check below output where is the discripencies. Please help if possible

    SSO ID: 900000001, Mfa Cat : NETWORK2 , Valid: 2020121714:36:21 SSO ID: 900000001, Mfa Cat : NETWORK2 , Valid: 2020121714:36:21 SSO ID: 900000001, Mfa Cat : NETWORK2 , Valid: 2020121714:36:21 SSO ID: 900000001, Mfa Cat : NETWORK2 , Valid: 2020121714:36:21 SSO ID: 900000001, Mfa Cat : NETWORK2 , Valid: 2020121714:36:21 SSO ID: 900000001, Mfa Cat : NETWORK2 , Valid: 2020121714:36:21 SSO ID: 900000001, Mfa Cat : NETWORK2 , Valid: 2020121714:36:21 SSO ID: 900000001, Mfa Cat : NETWORK2 , Valid: 2020121714:36:21 SSO ID: 266000003, Mfa Cat : Network1 ENV , Valid: 2021030808:34:59 SSO ID: 266000003, Mfa Cat : Network1 , Valid: 2021030808:34:59 SSO ID: 566000003, Mfa Cat : NETWORK2 , Valid: 2021031013:15:54 SSO ID: 566000003, Mfa Cat : Network1 ENV , Valid: 2021031013:15:54 SSO ID: 566000003, Mfa Cat : Network1 , Valid: 2021031013:15:54 SSO ID: 900000001, Mfa Cat : NETWORK2 , Valid: 2021031013:15:54 SSO ID: 566000003, Mfa Cat : NETWORK2 , Valid: 2021031013:15:54 SSO ID: 566000003, Mfa Cat : Network1 ENV , Valid: 2021031013:15:54 SSO ID: 566000003, Mfa Cat : Network1 , Valid: 2021031013:15:54

    My current code

    foreach my $p (0..$#cellC ) { if(exists $ssoidmfadates{$cellC[$p]}){ my $date_time; foreach $net(keys %{ $ssoidnetdates{$cellC[$p]} }) { push @VALUES , $date_time = + ParseDate((sort @{ $ssoidmfadates{$cellC[$p]}{{$net}} })[$_]) ; + my $date_time2 = maxstr (@VALUES); print " ID: $cellC[$p], Cat : $net , Valid: $hash5{$cellC[$p]}{ +$net}\n"; $worksh +eet->write($r17, 6, $net); $works +heet->write($r18, 7, maxstr ($date_time2)); } else { $worksheet->write($r17, 6, $no); $worksheet->write($r18, 7, $no); } $r17 += 1; $r18 +=1; } }
      Your code makes no sense. You don't show how you populate the hashes, the input data contain random html tags. Also, what do you think the following does?
      maxstr($date_time2)

      Help us to help you. Read and understand SSCCE. People who did received valuable help, their salaries were increased, and their life was happier. Those who didn't broke their legs, failed to quit smoking, and their pets died.

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11129754]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2024-04-18 15:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found