Reputation: 10073
In my perl program am using use POSIX qw( strftime );
library to perform unixtimestamp to date conversion as follows,
my $dt = strftime("%m/%d/%y", localtime($fields[0]));
Conversion is happening as expected but am getting the following error.
Prototype mismatch: sub main::strftime ($\@;$) vs none at
/usr/lib/perl5/5.8.5/Exporter.pm line 67.
at /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi/POSIX.pm line 19
Has anyone guide me what is the reason and how to get rid of it?
Upvotes: 4
Views: 5957
Reputation: 6782
I have faced the same error when I used a function before its been declare/defined. Although there can be more reasons since answer is already accepted, this may help someone.
sub func1{
func2();
}
sub func2{
}
solution was simply to move func2 before func1.
sub func2{
}
sub func1{
func2();
}
Upvotes: 1
Reputation: 386541
You either have two functions named strftime
(but then you would probably have another warning too), or you used strftime
before it was declared.
I always specify my imports explicitly, so I never run into the first problem.
use Date::Format qw( );
use POSIX qw( strftime );
Upvotes: 11