I have the following call in my script.
script_stats($runtime, $start);

The script is run from /Perl and the module is located in /Perl/Modules Here the entire (very small) module.

#!/usr/bin/perl use warnings; use strict; use DBD::mysql; package ScriptUpdate; our @ISA = qw(Exporter); our @EXPORT = qw(script_stats); # symbols to be exported by default + (space-separated) our $VERSION = 1.10; sub script_stats { my ($runtime, $rundate) = @_; chomp(my $filename = $0); chomp(my $currentuser=`whoami`); #Holds modified date for file my $mtime = stat($filename)->mtime; my $dbh = DBI->connect("DBI:mysql:database=ts_tool_track:host=xxxx +",'xxxx','xxxx') || die "$DBI::errstr\n"; my $sql = "SELECT ID, Name FROM ScriptDetails WHERE Name='$filenam +e'"; my $sth = $dbh->prepare ( $sql ); $sth->execute(); my @row = $sth->fetchrow_array(); if (exists $row[1] and $row[1] eq $filename) { #If run before \ exists update fields { my $sql = "UPDATE ScriptDetails SET LastModified=from_unix +time($mtime),LastRunTime='$runtime',LastRunDate=from_unixtime($rundat +e),LastRunBy='$currentuser', AvgRunTime = ((AvgRunTime + $runtime) / +2), TotalRuns = TotalRuns+1 WHERE ID='$row[0]' L +IMIT 1"; my $sth = $dbh->prepare ( $sql ); $sth->execute(); } } else { #If first time run, create entry { my $sql = "INSERT INTO ScriptDetails (Name, LastModified, +LastRunTime, LastRunDate, LastRunBy, AvgRunTime, TotalRuns) VALUES('$ +filename',from_unixtime($mtime),'$runtime',from_unixtime($rundate/100 +0),'$currentuser', '$runtime', '1')"; my $sth = $dbh->prepare ( $sql ); $sth->execute(); } } $sth->finish(); $dbh->disconnect(); } 1;

When I try and run it I get the following error.

Undefined subroutine &main::script_stats called at TLEQUERY.pl line 88.

Any hints? First time using packages. Least I got it to find it.


In reply to Help using self-made but very simple Module by kdmurphy001

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.