I’m trying to learn Perl and understand something about use and modules.
(Assume use strict; use warnings;)
I understand that use File::Find; loads all the subroutines of the module.
I understand that use File::Find qw(find); loads only the find subroutine of the module (although other subroutines my be used via File::Find::finddepth).
So what does File::Find (); do? Specifically, why the empty parens?
tl;dr : It says not to export anything instead of the default.
long version:
File::Find has
our @EXPORT = qw(find finddepth);, so those subs are exported by default. If we just use the module and then try to callfindit errors because I didn’t pass it the right arguments tofindbutfinddoes exist.Passing a list in the
usestatement overrides the defaults and exports only the subs that you ask for. An empty list means that none will be exported and it will error becausefinddoesn’t exist. Such: