On 10/30/18 11:24 PM, Martin McCormick wrote:
I can not seem to send Time::Piece any syntax it likes.
The file I am reading sends a time stamp that should
conform to RFC822 date stamps. An example of a stamp follows:
main::(lwx:204): my @obtime = split( /\,+/, $data->{observation_time_
rfc822} );
DB<2> print $obtime[1]
30 Oct 2018 20:53:00 -0500
whenever i print stuff for debugging i put it in [] or similar so i can
see white space or other odd things.
try print "[$obtime[1]]" and see what is really there.
DB<2> n
main::(lwx:205): my $t1 = Time::Piece->strptime( '$obtime[1]', '%D %b
%H:%M:%S %z' );
well, that will always fail. you are parsing the actual string
$obtime[1] and not its value. single quote are not allowing any
interpolation. you don't even need quotes to pass a scalar value and it
is usually a bug.
DB<2> n
Error parsing time at /usr/lib/i386-linux-gnu/perl/5.24/Time/Piece.pm line 481.
at /usr/lib/i386-linux-gnu/perl/5.24/Time/Piece.pm line 481.
Time::Piece::strptime("Time::Piece", "\$obtime[1]", "%D %b %H:%M:%S
%z")
called at lwx line 205
similar bug. you escape the $ so the timestamp value is not
interpolated. you are parsing the wrong string.
If there is some way to see what Time::Piece thinks I am
trying to tell it to do then one might be able to figure out what
is wrong but a miss is the same as close so I can't tell if I am
getting warm.
just stop with the extra quotes (single or double). just pass $obtime[1]
to strptime. i am guessing you are passing in Time::Piece as the class
in what would be an OO call. stick to the normal OO style there.
uri
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/