Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Creating and using a module

Expand Messages
  • Jenda Krynicky
    To: PBML From: John Mayson Date sent: Sat, 01 Dec 2001 12:24:53 -0600 Send reply
    Message 1 of 4 , Dec 1, 2001
    • 0 Attachment
      To: PBML <perl-beginner@yahoogroups.com>
      From: John Mayson <kc4vjo@...>
      Date sent: Sat, 01 Dec 2001 12:24:53 -0600
      Send reply to: perl-beginner@yahoogroups.com
      Subject: [PBML] Creating and using a module

      > I am trying to create and use a Perl module. I'm starting out very
      > simple just as an example. Anyone know why it doesn't work? The .pm
      > file are in the @INC.
      >
      > _____________________uniden.pm____________________
      > package uniden;
      >
      > use strict;
      >
      > $VERSION = "0.00";
      >
      > sub allclear {
      >
      > print "AC\n";
      >
      > }
      >
      > __END__

      You get something like "uniden.pm did not return a true value"
      right?

      The last command in a module must evaluate to a true value.

      Usualy you just end the modules with
      1;
      but you can do some tests during the module loading and return a
      false to report failure.

      I don't remember seeing a module that'd do that though.

      Jenda


      =========== Jenda@... == http://Jenda.Krynicky.cz ==========
      There is a reason for living. There must be. I've seen it somewhere.
      It's just that in the mess on my table ... and in my brain.
      I can't find it.
      --- me
    • jonathan.mark2@dyncorp.com
      use lib LIST adds the directories specified in LIST to Perl s search path. Since in your case uniden is a module and not a directory you get an error. If
      Message 2 of 4 , Dec 2, 2001
      • 0 Attachment
        'use lib LIST' adds the directories specified in LIST to Perl's
        search path. Since in your case uniden is a module and not a
        directory you get an error.

        If you remove the keyword lib and simply say 'use uniden' then Perl
        looks for uniden.pm in the same directory as uniden.pl. I fixed your
        script and it works. In fact, you can see your script's output at
        http://www.jonathanmark.com/tempo3.pl







        --- In perl-beginner@y..., John Mayson <kc4vjo@q...> wrote:
        > I am trying to create and use a Perl module. I'm starting out very
        simple just as an example. Anyone know why it doesn't work? The .pm
        file are in the @INC.
        >
        > _____________________uniden.pm____________________
        > package uniden;
        >
        > use strict;
        >
        > $VERSION = "0.00";
        >
        > sub allclear {
        >
        > print "AC\n";
        >
        > }
        >
        > __END__
        >
        >
        >
        > _________________uniden.pl______________________
        > #!/usr/bin/perl
        >
        > use lib uniden;
        >
        > uniden::allclear();
        > __END__
        >
        > --
        > John Mayson KC4VJO Linux/Perl/HP-UX/ICT
        > Austin, Texas 78729 30.4560N 97.7851W
        > jmayson.ee92@g... http://www.nyx.net/~jmayson
      Your message has been successfully submitted and would be delivered to recipients shortly.