in reply to Perl Module Education
Side note: you don't normally need a & in front of a subroutine name anyhow. In fact, adding one changes the semantics slightly. But the thing to read is the following excerpt from le manpage du jour, perldoc perlop:
"`->'" is an infix dereference operator, just as it is in C and C++. If the right side is either a `[...]', `{...}', or a `(...)' subscript, then the left side must be either a hard or symbolic reference to an array, a hash, or a subroutine respectively. (Or technically speaking, a location capable of holding a hard reference, if it's an array or hash reference being used for assignment.) See the perlreftut manpage and the perlref manpage. Otherwise, the right side is a method name or a simple scalar variable containing either the method name or a subroutine reference, and the left side must be either an object (a blessed reference) or a class name (that is, a package name). See the perlobj manpage.
Most modules use the standard Exporter module, which provides a standardized import mothod, although you are free to write your own. Read perldoc Exporter and poke around in a few of your favorite modules to see how Exporter gets used.
HTH
perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
overriding import; good or bad?
by t'mo (Pilgrim) on May 19, 2001 at 02:50 UTC | |
|
Re: Re: Perl Module Education
by radman (Novice) on May 18, 2001 at 22:51 UTC |