|No such thing as a small change|
Overloading Perl's Built-In'sby bbfu (Curate)
|on Jan 12, 2001 at 12:41 UTC||Need Help??|
bbfu has asked for the
wisdom of the Perl Monks concerning the following question:
I was looking at the Time::localtime module and noticed that it overloaded perl's built-in, localtime(). I was wondering how it it worked.
Looking to the internals, it seemed to me that it just exported (via Exporter) it's localtime() function. Nothing special. When I tried that, however, it didn't work.
Try as I might, I could not get my module to overload the built-in in the use'ing program. I thought I understood exporting fairly well. I even tried exporting by hand (via typeglob assignment, see The Second Try below) to no avail. (I know I'm doing this correctly because it works for variables and non-built-in functions.)
As far as I can tell, Time::localtime is not doing anything special besides exporting the function. There must be something I'm missing!
I've included a simple test program and two modules (the Exporter version and the typeglob version) below, as well as the output I get from the program and what the output should be.
Can anyone please help me to understand what's going on here
and what I'm doing wrong?
The First Module
The Second Try
The Output ^blah blah blah$
What The Output Should Be ^blah blah blah_this is a test$