Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re^6: timestamp in perl

by baperl (Sexton)
on Sep 24, 2011 at 21:27 UTC ( #927684=note: print w/replies, xml ) Need Help??

in reply to Re^5: timestamp in perl
in thread timestamp in perl

thanks, that's a lot of good info. maybe I can ask you another q :-) I am running this query, and it works fine in mySQL, i.e. md contains the right datetime value in mySQL. however, I don't believe mt is getting assigned md's value
my $check_inv_sql = "SELECT MAX(cdt) AS md FROM s_i ORDER BY cdt LIMIT + 1"; $sth=$dbh->prepare($s_query) or die $dbh->errstr; $sth->execute; my $mt; if (my $hash_ref = $sth->fetchrow_hashref) { $mt = $hash_ref->{'md'}; print "$mt\n";#this returns below error }
and the error it generates is
Use of uninitialized value $mt in concatenation (.) or string at + line 56.
It seems to me that I am not assigning md correctly to $mt. If that is indeed the case, how do I correct the above code....thx!

Replies are listed 'Best First'.
Re^7: timestamp in perl
by Util (Priest) on Sep 25, 2011 at 00:31 UTC

    It would help to know whether the key {'md'} is missing from the hash, or the key exists but the value undefined. Also, what else is in the hash?

    What output do you get with this change?

    # ... same code as above use Data::Dumper; $Data::Dumper::Useqq = 1; if ( my $hash_ref = $sth->fetchrow_hashref ) { print Dumper $hash_ref; }

      my apologies....I was preparing and executing the wrong query as you'll notice in my code....the marvels of copy and paste. your code on the Data::Dumper is helpful, so thanks for'll save me trouble in the future :-)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2020-07-14 11:06 GMT
Find Nodes?
    Voting Booth?

    No recent polls found