Question

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?

Était-ce utile?

La solution

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 );

Autres conseils

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();
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top