PERL: Calling a sub routine from another module - help!!!

Hi,

I am an occasional PERL user. I am trying to call a sub routine (passing parameters) in perl module from a driver .pl file. I have been "tinkering" for a while now and have confused myself.

Could someone please look at the code below and spot where I am going wrong.

testPerl.pl

#!/usr/local/bin/perl -w
use strict;
use call;
    my $to_directory = "F:\\Received";   # The target directory
    my $snode        = "cd.nt.arc.trl";   # The Secondary node
    my $directory    = "\/data\/enva\/MS\/msarchive";   # cd log dirs
    my $from_directory = "R:\\"; # The directory where lis files are kept
    my $report_dir   = "\/data\/enva\/MS\/msarchive\/archive_report";   # Report Directory
    my $subsystem    = "M";   # e.g. M for Message Server
my $date = "ADATE";
my $filename = "dir$date.lis";
$call->get_sentfilecount($to_directory, $snode, $directory, $from_directory, $report_dir, $subsystem);
call::get_sentfilecount($to_directory, $snode, $directory, $from_directory, $report_dir, $subsystem);
 

call.pm

#!/usr/local/bin/perl -w
use strict;
package call;

sub get_sentfilecount
{
    use POSIX qw(strftime);
    my $to_directory = shift;   # The target directory
    my $snode        = shift;   # The Secondary node
    my $directory    = shift;   # cd log dirs
    my $from_directory = shift; # The directory where lis files are kept
    my $report_dir   = shift;   # Report Directory
    my $subsystem    = shift;   # e.g. M for Message Server
    my $line         = undef;
    my $lastline     = undef;
    my $CD_OUT       = undef;
    my $CD_IN        = undef;
    
    my $date = strftime "%d%m%Y", localtime;
    my $filename = "dir$date.lis";
    my $trans_file = $from_directory.$subsystem."\\". $filename;
    print "$trans_file";
    # connect direct stuff goes here
    if (!open(CDFILE, ">$directory/mstont2.cd"))
    {
        $ArchiveServer::errstr = "can't open mstont2.cd for writing: $!";
        return 0;
    }
    # Form the Connect:Direct copy command and write it into the file mstont2.cd
    #
    # The transfer should be made in binary mode with no translation
    # The transfer mode should be described in both the from and to part of the copy
    # statement
    #
    my $get_liscount = qq(
                       mstont2 process snode=$snode
                       step01
                         run task snode (PGM=WinNT)
                         sysopts="cmd(dir $to_directory\\*.TXT  > $from_directory\\dir$date.lis) desktop(no)"
                       step02
                       copy from (file =$trans_file
                                      snode
                                      sysopts="datatype(binary) xlate(no)"
                                     )
                                to   (file = $report_dir
                                      pnode
                                      sysopts=":datatype=binary:xlate=no:"
                                      disp = rpl
                                     )
                       pend;
                      );
    print CDFILE $get_liscount;
    close(CDFILE);
    my $errcd = 0;
    # Open Connect:Direct CLI and submit job in file mstont2.cd
    eval
    {
        $errcd = open2($CD_OUT, $CD_IN, 'direct 2>/dev/null');
    };
    if ($@)
    {
       $ArchiveServer::errstr = "Cannot Create command for file transfer due to: $!";
       return 0;
    }
    print $CD_IN "submit file=$directory/mstont2.cd;\n";
    print $CD_IN "quit;\n";
    close($CD_IN);
    my $OKflag = 0;
    while ($line = <$CD_OUT>)
    {
        chomp($line);
        if ($line =~ "Process Submitted")
        {
           $OKflag = 1;
        }
        $lastline = $line;
    }
    if (0 == $OKflag )
    {
       $ArchiveServer::errstr = "Cannot create submit process command for file transfer due to : $lastline";
       return 0;
    }
    close($CD_OUT);
    if ($@)
    {
       $ArchiveServer::errstr = "Cannot Create command for file transfer due to: $!";
       return 0;
    }
    print $CD_IN "submit file=$directory/mstont2.cd;\n";
    print $CD_IN "quit;\n";
    close($CD_IN);
    my2 $OKflag = 0;
    while ($line = <$CD_OUT>)
    {
        chomp($line);
        if ($line =~ "Process Submitted")
        {
           $OKflag = 1;
        }
        $lastline = $line;
    }
    if (0 == $OKflag )
    {
       $ArchiveServer::errstr = "Cannot create submit process command for file transfer due to : $lastline";
       return 0;
    }
    close($CD_OUT);
    return 1;
}
1;

When I run it, I get the following error:

$ perl -w testPerl.pl
Global symbol "$call" requires explicit package name at testPerl.pl line 15.
Execution of testPerl.pl aborted due to compilation errors.

Thanks

Chris

---------- Post updated at 04:48 PM ---------- Previous update was at 04:23 PM ----------

OK got it (the PERL) to work:

#!/usr/local/bin/perl -w
use strict;
use call;
    my $to_directory = "F:\\Received";   # The target directory
    my $snode        = "cd.nt.arc.trl";   # The Secondary node
    my $directory    = "\/data\/enva\/MS\/msarchive";   # cd log dirs
    my $from_directory = "R:\\"; # The directory where lis files are kept
    my $report_dir   = "\/data\/enva\/MS\/msarchive\/archive_report";   # Report Directory
    my $subsystem    = "M";   # e.g. M for Message Server
my $date = "ADATE";
my $filename = "dir$date.lis";
##$call->get_sentfilecount($to_directory, $snode, $directory, $from_directory, $report_dir, $subsystem);
my $call = call::get_sentfilecount($to_directory, $snode, $directory, $from_directory, $report_dir, $subsystem);

#!/usr/local/bin/perl -w
use strict;
package call;

sub get_sentfilecount
{
    use POSIX qw(strftime);
    my $to_directory = shift;   # The target directory
    my $snode        = shift;   # The Secondary node
    my $directory    = shift;   # cd log dirs
    my $from_directory = shift; # The directory where lis files are kept
    my $report_dir   = shift;   # Report Directory
    my $subsystem    = shift;   # e.g. M for Message Server
    my $line         = undef;
    my $lastline     = undef;
    my $CD_OUT       = undef;
    my $CD_IN        = undef;
    
    my $date = strftime "%d%m%Y", localtime;
    my $filename = "dir$date.lis";
    my $trans_file = $from_directory.$subsystem."\\". $filename;
    print "$trans_file";
    # connect direct stuff goes here
    if (!open(CDFILE, ">$directory/mstont2.cd"))
    {
        $ArchiveServer::errstr = "can't open mstont2.cd for writing: $!";
        return 0;
    }
    # Form the Connect:Direct copy command and write it into the file mstont2.cd
    #
    # The transfer should be made in binary mode with no translation
    # The transfer mode should be described in both the from and to part of the copy
    # statement
    #
    my $get_liscount = qq(
                       mstont2 process snode=$snode
                       step01
                         run task snode (PGM=WinNT)
                         sysopts="cmd(dir $to_directory\\*.TXT  > $from_directory\\dir$date.lis) desktop(no)"
                       step02
                       copy from (file =$trans_file
                                      snode
                                      sysopts="datatype(binary) xlate(no)"
                                     )
                                to   (file = $report_dir
                                      pnode
                                      sysopts=":datatype=binary:xlate=no:"
                                      disp = rpl
                                     )
                       pend;
                      );
    print CDFILE $get_liscount;
    close(CDFILE);
    my $errcd = 0;
    # Open Connect:Direct CLI and submit job in file mstont2.cd
    eval
    {
        $errcd = open2($CD_OUT, $CD_IN, 'direct 2>/dev/null');
    };
    if ($@)
    {
       $ArchiveServer::errstr = "Cannot Create command for file transfer due to: $!";
       return 0;
    }
    print $CD_IN "submit file=$directory/mstont2.cd;\n";
    print $CD_IN "quit;\n";
    close($CD_IN);
    my $OKflag = 0;
    while ($line = <$CD_OUT>)
    {
        chomp($line);
        if ($line =~ "Process Submitted")
        {
           $OKflag = 1;
        }
        $lastline = $line;
    }
    if (0 == $OKflag )
    {
       $ArchiveServer::errstr = "Cannot create submit process command for file transfer due to : $lastline";
       return 0;
    }
    close($CD_OUT);
    if ($@)
    {
       $ArchiveServer::errstr = "Cannot Create command for file transfer due to: $!";
       return 0;
    }
    print $CD_IN "submit file=$directory/mstont2.cd;\n";
    print $CD_IN "quit;\n";
    close($CD_IN);
    my2 $OKflag = 0;
    while ($line = <$CD_OUT>)
    {
        chomp($line);
        if ($line =~ "Process Submitted")
        {
           $OKflag = 1;
        }
        $lastline = $line;
    }
    if (0 == $OKflag )
    {
       $ArchiveServer::errstr = "Cannot create submit process command for file transfer due to : $lastline";
       return 0;
    }
    close($CD_OUT);
    return 1;
}
1;

Just need to get the Connect Direct bit to work now!