See use for details. In short, during the compilation phase, Perl checks whether Log::Log4perl is already in %INC, if not, it searches @INC for it (Log/Log4perl.pm), compiles it (if the module returns a true value, the compilation phase continues, otherwise it stops), and calls its import with 'get_logger' as an argument. It usually imports the get_logger subroutine to the caller's namespace.BTW, a semicolon is missing at the end of the line.
| [reply] [d/l] |
You imported the get_logger function from the Log::Log4perl module, and now you may call it in your code.
See also:
| [reply] [d/l] [select] |
G'day carlriz,
You might also be interested in the Exporter module.
It explains about the import list, that's qw(get_logger) in your example.
There's also information on Specialised Import Lists, which you'll encounter from time to time, or may choose to use yourself.
A common example is:
use Some::Module qw{:all};
| [reply] [d/l] [select] |
If you look at the documentation for any CPAN module, you might find that it supplies a lot of subroutine definitions that you really don’t want in your code. Or, you may simply want to refer to a particular routine or set of routines, and to clearly document to the Gentle Programmer who will one day follow in your footsteps just where those routines are coming from. This syntax uses the specified module, but then only exposes to view the subroutines that are named in the list ... not all of the subroutines that the module might contain. And of course, in so doing, it explicitly identifies the origin of those routines ... which, BTW, is tremendously helpful in understanding unfamiliar-to-you code!
See: perldoc -f use
| |