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

Thanks for fixing your formatting.

The other response is correct: "use PrintName", vs package Printname... these things are case sensitive.

Also, if I recall, Windows filenames are not case-sensitive, but many other operating systems are. For all those OS's that are case-sensitive, when your module starts out with package PrintName;, the file it lives in should usually be named PrintName.pm, not printname.pm. In your environment case sensitivity of filenames is probably not an issue, but someday you'll discover the rest of the world and realize what you've been missing. ;)


Dave

Replies are listed 'Best First'.
Re^4: Custom Module question
by imfaus (Initiate) on Dec 04, 2014 at 20:03 UTC
    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");

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

      poj
        you guys rock this fixed the problem