Hello choroba,
That's what use does.
Yes, according to the documentation for use, it calls the import function:
It is exactly equivalent to
BEGIN { require Module; Module->import( LIST ); }
except that Module must be a bareword.
But how does use call a function that hasn’t been defined anywhere? Are you saying that use itself creates an import function for the target module? (And if so, what are the contents of that function?)
| [reply] [d/l] [select] |
I haven't checked the source, but it seems so, don't you think? The created sub seems empty:
~ $ perl -lwe '{package My; sub x {}} $INC{"My.pm"}=1; eval "use My";
+use Data::Dumper; $Data::Dumper::Deparse = 1; print Dumper \&$_ for v
+alues %{"My::"}'
$VAR1 = sub {
package My;
};
$VAR1 = sub ;;
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord
}map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
| [reply] [d/l] [select] |
That makes sense, at least in retrospect. As was mentioned earlier, use() is equivalent to require() followed by import(). The minimum implementation is probably to have class UNIVERSAL, which all Perl classes inherit from, have an empty import(), which in fact it does.
So, to go back to the original question, it appears the most useful answer is that your Perl class in fact gets an import() method from somewhere, but the default one, inherited from UNIVERSAL, does nothing, so presumably they felt no need to document it. It's not documented under UNIVERSAL either.
| [reply] [d/l] [select] |