in reply to Re^3: Custom Module question
in thread Custom Module question

Ok I made your changes when I run the script I receive the following error. BTW thanks again I have used perl for a while but I am learning a good deal from your help. New to modules. Thanks Again C:\Scripts>perl testmodule.pl Subroutine print_name redefined at C:/Perl64/site/lib/printname/PrintName.pm line 10. Hello, John Module
use Printname; use strict; use warnings; use parent qw/ Exporter /; our @EXPORT_OK = qw/ print_name /; sub print_name { my($name) = @_; print "\nHello, $name\n"; } 1;
script
#!/usr/bin/perl package main; use strict; use warnings; use lib "C:/Perl64/lib/printname"; use lib "C:/Perl64/site/lib/printname"; # use PrintName qw/ print_name /; use PrintName; print_name("John");

Replies are listed 'Best First'.
Re^5: Custom Module question
by poj (Abbot) on Dec 04, 2014 at 20:31 UTC

    The first line of your module should be
    package PrintName;
    not use Printname;

    poj
      you guys rock this fixed the problem

        Yes, but like this
        our @EXPORT_OK = qw/ print_name run_system /;

        see qw
        poj