Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Find maximum (Activity) date from array hash.

by CountZero (Bishop)
on Jun 02, 2020 at 20:08 UTC ( #11117608=note: print w/replies, xml ) Need Help??


in reply to Find maximum (Activity) date from array hash.

A few things:

  • You will have to dereference $_ : $_->{'Activity Date'}
  • = isn't a comparison operator, it is the assignment operator. Use == instead for numerical tests. But you really need eq to check if both dates are the same.
  • Finally, to see if one date is before or after another, you cannot use > or <. At least not if you use this date-format. The ISO date format (YYYY-MM-DD) can do that more easy. So either transform your date format into the ISO format of use one of the many Date or DateTime modules on CPAN.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Replies are listed 'Best First'.
Re^2: Find maximum (Activity) date from array hash.
by Sami_R (Sexton) on Jun 02, 2020 at 23:41 UTC

    Thank you CountZero

    Based on your notes, have used hippo's code with ISO date format (YYYY-MM-DD) and compared the date like

    $maxdate = $date if $date gt $maxdate;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2020-09-29 04:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (145 votes). Check out past polls.

    Notices?