Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

arno's scratchpad

by arno (Scribe)
on Aug 23, 2004 at 14:46 UTC ( #385088=scratchpad: print w/ replies, xml ) Need Help??

1) AUTOLOAD subroutine from Time::Hires.pm
2) What i typed
3) The error message i got

I'm new to Autoloading and i face with a problem which i'd like to solve on my own.
I read the documentation of various things including AutoLoader module, UNIVERSAL class, and others but i still don't understand where constant subroutine comes from.
What i understand is that AUTOLOAD is executed when location of a subroutine failed that's to say the symbol name isn't in the stash %::.
Here, i believe $constname contains this unfound symbol because of the affectation :
($constant = $AUTOLOAD) =~ s/.*:://;
I believe constant($constname) is responsible of this error message as perldiag doesn't describe a similar compilation failure.

1) -- from Time::HiRes.pm :
sub AUTOLOAD { my $constname; ($constname = $AUTOLOAD) =~ s/.*:://; die "&Time::HiRes::constant not defined" if $constname eq 'constan +t'; my ($error, $val) = constant($constname); if ($error) { die $error; } { no strict 'refs'; *$AUTOLOAD = sub { $val }; } goto &$AUTOLOAD; }
2) --- what i did :

# perl -MTime::HiRes -e 1
3) --- what i get : ( i deleted what @INC contains in the output )

Can't locate loadable object for module Time::HiRes in @INC (@INC contains: ... ) at -e line 0
Compilation failed in require. BEGIN failed--compilation aborted.
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2014-09-16 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (46 votes), past polls