in reply to Help using self-made but very simple Module

Add use Exporter; at the top of your module. I.e. (simplified):

# your module ScriptUpdate.pm package ScriptUpdate; use Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(script_stats); sub script_stats { print "script_stats(): ...\n"; } 1; # the main program: #!/usr/bin/perl use lib "./Modules"; use ScriptUpdate; script_stats();

Note that our @ISA = qw(Exporter); does not load Exporter.

(Alternatively, add strictures... which will indirectly have the same effect, i.e. loading Exporter as a side effect under the hood... :)

Replies are listed 'Best First'.
Re^2: Help using self-made but very simple Module
by kdmurphy001 (Sexton) on Oct 12, 2009 at 14:56 UTC
    Got me farther, had 2 more error messages pop up, fixed them and now stuck on this one.

    Can't call method "mtime" without a package or object reference at Modules/ScriptUpdate.pm line 2

    This works if i use it as a sub_routine. I added the File::stat lib but still get the error.

    Here the code that line references.

    my $mtime = stat($filename)->mtime;

    This is in the package. Do I need to bless something? Reading up on bless now but that's all new to me.

      You'd need to use File::stat in the package, as by-name stat fields are not core Perl syntax.

      Alternatively, simply write (stat $filename)[9].

        That did it! WOOT! THanks much (Switching it to just stat and 9