Placing handmade modules

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default Placing handmade modules

    Hi all,

    I use the following code to use a module I made:

    use lib "$ENV{HOME}/Library/Scripts/Modules";

    use Test::Template;

    my ($update_path, $gallery_title) = &Test::Template::choose();

    The module sits in /Users/jan/Library/Scripts/Modules/Test. Now Perl tells me it cannot locate the subroutine "choose". If I place Template.pm directly into the path set in the "use lib" line and remove the "Test::" at both places, everything works fine.

    I read in the camel that double colon separators in a module name would be translated to a directory structure when Perl searches for them.

    Why doesn't Perl do it for me?

    Thanks,

    Jan
    --
    How many Microsoft engineers does it take to screw in a lightbulb? None. They just redefine "dark" as the new standard.
    Jan Eden Guest

  2. Similar Questions and Discussions

    1. placing flash over w3d
      Hi i want to be able to place a flash swf file on top of a w3d scene on stage. every time i do this the flash file is sent behind the w3d. Is it...
    2. Placing EPS vs. AI into Indesign 2.0
      After placing .eps files (created in Illustrator) into Indesign 2.0 there is a slight cropping of the edge of the graphic. And when placing the same...
    3. Placing EPS or images in Ai
      Has anyone else experienced this one?...Go to "place" and image ...now before actually selecting the image to place ...hit cancel instead,,,INSTANT...
    4. placing pdf as transparent
      Hello, I have a bunch of pdf graphichs made with StarOffice Starcalc I want to place in an Indesign document. These pdf show a white...
    5. Help me with "handmade" messageboard
      Hello, Tom! You wrote on Sun, 28 Mar 2004 14:53:16 GMT: TT> On 27-Mar-2004, "Nurchi BECHED" <nurchi@telus.net> wrote: TT> First, you...
  3. #2

    Default RE: Placing handmade modules

    > my ($update_path, $gallery_title) = &Test::Template::choose();

    Can I assume that your module has the line "package Test::Template;" at the
    top of the file? If not, that is why.
    > use Test::Template;
    This says "load {lib directory}/Test/Template.pm.
    > &Test::Template::choose();
    This says "execute choose() in the Test::Template package".

    Rob


    -----Original Message-----
    From: Jan Eden [mailto:lists@jan-eden.de]
    Sent: Monday, January 26, 2004 11:39 AM
    To: Perl Lists
    Subject: Placing handmade modules


    Hi all,

    I use the following code to use a module I made:

    use lib "$ENV{HOME}/Library/Scripts/Modules";

    use Test::Template;

    my ($update_path, $gallery_title) = &Test::Template::choose();

    The module sits in /Users/jan/Library/Scripts/Modules/Test. Now Perl tells
    me it cannot locate the subroutine "choose". If I place Template.pm directly
    into the path set in the "use lib" line and remove the "Test::" at both
    places, everything works fine.

    I read in the camel that double colon separators in a module name would be
    translated to a directory structure when Perl searches for them.

    Why doesn't Perl do it for me?

    Thanks,

    Jan
    --
    How many Microsoft engineers does it take to screw in a lightbulb? None.
    They just redefine "dark" as the new standard.

    --
    To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
    For additional commands, e-mail: [email]beginners-help@perl.org[/email]
    <http://learn.perl.org/> <http://learn.perl.org/first-response>

    Rob Hanson Guest

  4. #3

    Default Re: Placing handmade modules


    On Jan 26, 2004, at 8:38 AM, Jan Eden wrote:
    [..]
    > The module sits in /Users/jan/Library/Scripts/Modules/Test. Now Perl
    > tells me it cannot locate the subroutine "choose". If I place
    > Template.pm directly into the path set in the "use lib" line and
    > remove the "Test::" at both places, everything works fine.
    sounds like your package line in the Template.pm
    file is set as

    package Template;

    and NOT as

    package Test::Template;

    Hence what you wanted to do is

    use lib "$ENV{HOME}/Library/Scripts/Modules";
    use Template;
    ...
    my ($update_path, $gallery_title) = &Test::Template::choose();
    > I read in the camel that double colon separators in a module name
    > would be translated to a directory structure when Perl searches for
    > them.
    Yes and no - the yes part is that IF the package line and
    the file name are set appropriately.

    This is one of the reasons that the perldoc advocates
    doing the start of a perl module with h2xs

    cf perldoc h2xs

    so that you can start off at least modestly sanely

    my traditional rant on PM's is at
    <http://www.wetware.com/drieux/CS/lang/Perl/PM/quick_pm.html>

    When I am brewing up a new module, I then of course use
    something like

    <http://www.wetware.com/drieux/CS/lang/Perl/PM/PerlInstall.plx>

    so that i can install the module in my home directory.

    ciao
    drieux

    ---

    Drieux Guest

  5. #4

    Default Re: Placing handmade modules

    Thanks Rob and drieux,

    you were both right. The package line read

    package Template;

    Since I noticed my error just one minute after asking for help on the list,I tried to send a followup, but - alas! - my provider's SMTP server deniedconnections for about two hours.

    Now I learned some more perlish behaviour: double colons are used for both the namespace and the replicated directory structure.

    Thanks again,

    Jan

    drieux wrote:
    >
    >On Jan 26, 2004, at 8:38 AM, Jan Eden wrote:
    >[..]
    >> The module sits in /Users/jan/Library/Scripts/Modules/Test. Now Perl
    >> tells me it cannot locate the subroutine "choose". If I place
    >> Template.pm directly into the path set in the "use lib" line and
    >> remove the "Test::" at both places, everything works fine.
    >
    >sounds like your package line in the Template.pm
    >file is set as
    >
    > package Template;
    >
    >and NOT as
    >
    > package Test::Template;
    >
    >Hence what you wanted to do is
    >
    > use lib "$ENV{HOME}/Library/Scripts/Modules";
    > use Template;
    > ...
    > my ($update_path, $gallery_title) = &Test::Template::choose();
    >
    >> I read in the camel that double colon separators in a module name
    >> would be translated to a directory structure when Perl searches for
    >> them.
    >
    >Yes and no - the yes part is that IF the package line and
    >the file name are set appropriately.
    >
    >This is one of the reasons that the perldoc advocates
    >doing the start of a perl module with h2xs
    >
    > cf perldoc h2xs
    >
    >so that you can start off at least modestly sanely
    >
    >my traditional rant on PM's is at
    ><http://www.wetware.com/drieux/CS/lang/Perl/PM/quick_pm.html>
    >
    >When I am brewing up a new module, I then of course use
    >something like
    >
    ><http://www.wetware.com/drieux/CS/lang/Perl/PM/PerlInstall.plx>
    >
    >so that i can install the module in my home directory.
    >
    >ciao
    >drieux
    >
    >---
    >
    >
    --
    There's no place like ~/
    Jan Eden Guest

  6. #5

    Default Re: Placing handmade modules


    On Jan 26, 2004, at 2:45 PM, Jan Eden wrote:
    > Now I learned some more perlish behaviour: double colons are used for
    > both the namespace and the replicated directory structure.
    actually, the double colons indicate a name space,
    and IF the name space IS external, then it is
    left to the File System Implementation of 'use'
    and/or 'require' how to go and find the appropriate file.

    As you will have noticed from say

    BEGIN {
    package Foo::Bar;
    ......


    } # end begin
    # back in package main::*

    One can put packages into a script and use them,
    without having to externalize them as a Perl Module.


    ciao
    drieux

    ---

    Drieux Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139