Too little detail in one respect: I don't know what different behavior you'd like to see. But here's a way to transform a field while keeping the inside of your loop nice and field-agnostic -- I'll guess that you want to strip the time and display just the date.

use Data::Dumper; my %field_filter = (creation_date => sub { my $datetime = shift; retur +n (split ' ', $datetime)[0] } ); my @fields = (qw(creation_date a b)); my @hash_ops = ({a => '', b => 2, creation_date => '12/31/2005 12:32:1 +1'}, {a => 5, b => 0, creation_date => '23/01/2222 13:14:15'}); my @loop_data; for my $hash_op (@hash_ops) { my %row_data; foreach my $field (@fields) { if ($hash_op->{$field}) { $row_data{$field} = exists $field_filter{$field} ? $field_filter +{$field}->($hash_op->{$field}) : $hash_op->{$field}; } else { $row_data{$field} = '-'; } } push (@loop_data, \%row_data); } print Dumper(\@loop_data)

This outputs:

$VAR1 = [ { 'a' => '-', 'creation_date' => '12/31/2005', 'b' => 2 }, { 'a' => 5, 'creation_date' => '23/01/2222', 'b' => '-' } ];

In reply to Re: Handling MS-Access date time by Zed_Lopez
in thread Handling MS-Access date time by k_rajesh

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.