shragi
asked on
perl date conversion
Hi - I am trying to convert effective date format from 11/20/2014 to 20141120.
I am writing that as a part of my script, and please check the attached script.
When i use the below script and run it seperately it works but when I use it as a part of my script it fails and gives me error message saying "can't use string ("Time::Piece") as an array ref while "Strict refs" in use at c:/Strawberry/perl/lib/Tim e/Piece.pm line 452, <INFILE> line 5"
use strict;
use warnings;
use Time::Piece;
my $dt = Time::Piece->strptime('01/ 20/2014', '%m/%d/%Y');
print $dt->strftime('%Y%m%d');
let me know what needs to be modified in my script.
Thanks
TESTSCRIPT.txt
I am writing that as a part of my script, and please check the attached script.
When i use the below script and run it seperately it works but when I use it as a part of my script it fails and gives me error message saying "can't use string ("Time::Piece") as an array ref while "Strict refs" in use at c:/Strawberry/perl/lib/Tim
use strict;
use warnings;
use Time::Piece;
my $dt = Time::Piece->strptime('01/
print $dt->strftime('%Y%m%d');
let me know what needs to be modified in my script.
Thanks
TESTSCRIPT.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You did not remove the ' ' around $effectiveDate
As ozo said, you need to remove the single quotes around the $effectiveDate variable. You are trying to convert the literal string $effectiveDate (which will obviously fail since it is not a date) rather than the value of $effectiveDate.
ASKER
"error parsing time at C:/strawberry/perl/lib/tim
my $dt = Time::Piece->strptime('$ef
print $dt->strftime('%Y%m%d');
also tried
my $dt = Time::Piece->strptime('$ef
print $dt->strptime('%Y%m%d');
Thanks