Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Subroutine Time::HiRes::Time redefined ... Help

by rminner (Chaplain)
on May 07, 2018 at 01:59 UTC ( #1214133=note: print w/replies, xml ) Need Help??

in reply to Subroutine Time::HiRes::Time redefined ... Help

In perl on windows you will get a warning for every subroutine in a Module being redefined, if somewhere in your code (or in some submodule) the given Module is used or required with the correct case, and somewhere else it is loaded with a missmatched case. e.g. in one place it is loaded using the correct case:
use Time::HiRes;
an it is loaded somewhere else with the wrong case:
# missspelled module name use TIME::HiRes;
Since TIME::HiRes is not loaded yet (only Time::HiRes is loaded), it will be loaded again, thus redefining the subroutines. The cause is Perl being case sensitive and the windows filesystem being case insensitive.

Replies are listed 'Best First'.
Re^2: Subroutine Time::HiRes::Time redefined ... Help
by afoken (Canon) on May 07, 2018 at 18:14 UTC

    Good point. Having a look at %INC could help:

    C:\>perl -MData::Dumper -MdaTA::duMPer -E "say Dumper(\%INC)" $VAR1 = { 'daTA/' => 'C:/strawberry/perl/lib/daTA/', 'warnings/' => 'C:/strawberry/perl/lib/warnings/r', '' => 'C:/strawberry/perl/lib/', '' => 'C:/strawberry/perl/lib/', '' => 'C:/strawberry/perl/lib/', '' => 'C:/strawberry/perl/lib/', '' => 'C:/strawberry/perl/lib/', '' => 'C:/strawberry/perl/lib/', '' => 'C:/strawberry/perl/lib/', 'Data/' => 'C:/strawberry/perl/lib/Data/', '' => 'C:/strawberry/perl/lib/' }; C:\>

    Sorting the %INC keys definitively helps:

    C:\>perl -MData::Dumper -MdaTA::duMPer -E "say for sort { lc($a) cmp l +c($b) } keys %INC" daTA/ Data/ warnings/ C:\>

    But the best way is to let perl find the problematic module name:

    C:\>perl -MData::Dumper -MdaTA::duMPer -E "my %oops; $oops{lc $_}++ fo +r keys %INC; say for grep { $oops{$_}>1 } keys %oops" data/ C:\>


    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2021-02-26 12:16 GMT
Find Nodes?
    Voting Booth?

    No recent polls found