in reply to Re: check for date and time
in thread check for date and time

How to create a hash of id as key, value with the latest date and time.

Replies are listed 'Best First'.
Re^3: check for date and time
by colwellj (Monk) on Feb 26, 2010 at 05:48 UTC
    try something like;
    #!/usr/bin/perl -w use strict; my %idhash; my @ids; foreach (@id_list){ #split up your input line into something useful @ids = split (/-->/,$_); # check to see if that date is already in your hash and if it is ne +wer if(defined($idhash{$ids[1]}) && $idhash{$ids[1]} >= $ids[2]){ next }else{ #populate your hash $idhash{$ids[1]} = $ids[2]; } } #then print your dates from the hash using foreach key
      #!/usr/bin/perl use XML::Simple; @files = `ls`; use XML::Parser; foreach $input_file (@files){ my $xml_parser = XML::Simple->new(); my $data = $xml_parser->XMLin($input_file); my $date = $data->{'root'}->{'date'}; my $time = $data->{'root'}->{'time'}; }
      How to store only one date file which has large date and time
        What have you tried?
        If you want to reference the date and time you could look at a structure of arrays or if you want to search by date, hashes.
        Most of the monks here will be happier to help if you show what you tried.