Perl Modules and packages

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

           I am new to perl scripting i want to know the were the perl modules and packages are in perl scripting language.


Re: Perl Modules and packages

On 14/12/13 08:38, wrote:
Quoted text here. Click to load it

Not sure I understand your question.  Perl comes with a large set of  
"standard modules", which are installed in system libraries when you  
install Perl.  You can find out what they are by typing

   perl -lE "print for @INC"

If you're looking for additional modules, not supplied as standard, then  
CPAN is a good place to look.  But the providers of your operating  
system may have more specific repositories.  ActiveState Perl for  
Windows, for example, has the "PPM" mechanism, which provides access to  
specifically Windows version of the modules.  And Ubuntu provides most  
of them via the official repositories.

Does that answer your question?  Post again more specifically if not.


Henry Law            Manchester, England

Re: Perl Modules and packages

Quoted text here. Click to load it

This sounded interesting.  So I ran it on my system and got:

perl -lE "print for @INC"
Unrecognized switch: -E  (-h will show valid options).

-ver reveals that v5.8.8 is installed.

John Black

Re: Perl Modules and packages

Quoted text here. Click to load it

You're running something old or not on a linux/MacOS system:

dexlabs-ml[17]~ % perl -lE "print for @INC"
dexlabs-ml[18]~ % perl --version

This is perl 5, version 12, subversion 4 (v5.12.4) built for  

Copyright 1987-2010, Larry Wall

Perl may be copied only under the terms of either the Artistic License  
or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to  
Internet, point your browser at /, the Perl Home Page.

DeeDee, don't press that button!  DeeDee!  NO!  Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]

Re: Perl Modules and packages

On 16/12/13 03:11, John Black wrote:
Quoted text here. Click to load it

You worried me there, John; but I checked rapidly and it does work here  
on 5.14.2 on Linux ... phew!

Wonder where the OP is; two days and counting.


Henry Law            Manchester, England

Re: Perl Modules and packages

Quoted text here. Click to load it

The -E switch was introduced in v5.10. Use -e instead:

    perl -le 'print for @INC'

(the difference between -e and -E is that -E enables all current
features, but this simple one-liner doesn't use any, so there is no
difference in this case)

I'm not sure whether that answers the OP's question, though.


   _  | Peter J. Holzer    | Fluch der elektronischen Textverarbeitung:
|_|_) |                    | Man feilt solange an seinen Text um, bis
| |   |         | die Satzbestandteile des Satzes nicht mehr
__/   | | zusammenpaßt. -- Ralph Babel

Re: Perl Modules and packages

Quoted text here. Click to load it

It does.  
This command lists all locations, where the Perl interpreter (note the
lower case 'perl' in the OPs question) is looking for modules and
The real question is if this is what the OP meant to ask. But that is
something only he can answer.


Re: Perl Modules and packages

You have to read the documentation butfFor a quick start create the  
following three files at the same directory

    use strict;
    use warnings;
    use feature 'say';
    use summer qw/&fun1 &fun2 &sun1 $var/;

    say fun1("hello");
    say fun2("hello");
    say sun1("hello");
    say "var is $var";
    $var = 153;
    say summer::fun3("hello");
    say $summer::foo;

    package summer;
    use     spring;
    use    strict;
    use    warnings;
    use     Exporter;
    our     $VERSION    = '0.1.1';
    our    @ISA        = qw/Exporter spring/;
    our    %EXPORT_TAGS    = ();
    our    @EXPORT        = qw/&fun1 $var/;
    our    @EXPORT_OK    = qw/&fun2 &sun1/;
    our    @EXPORT_FAIL    = qw//;

    our $var = 'Summer';
    our $foo = 'Winter';

    sub fun1 { return uc $_[0]                }
    sub fun2 { return "Hello World from package ". __PACKAGE__}
    sub fun3 { return "$var is $var"        }

    1; __END__ #<EMD OF MODULE>

    BEGIN    {
    package spring;
    use    strict;
    use    warnings;
    use     Exporter;
    our     $VERSION    = '0.1.1';
    our    @ISA        = qw/Exporter/;
    our    %EXPORT_TAGS    = ();
    our    @EXPORT        = qw/&sun1 &sun2/; # exprort now
    our    @EXPORT_OK    = qw//;    # export on demand
    @EXPORT_FAIL        = qw//;

    my $foo = 'hello';

    sub sun1 { return "Hello World from package ". __PACKAGE__  }
    sub sun2 { return "I am package spring" }

    }1; __END__ #<EMD OF MODULE>

run and you are ready to go !

Site Timeline