Perl Modules and packages

Discussion in 'Perl Misc' started by nraju531@gmail.com, Dec 14, 2013.

  1. Guest

    Hi,

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


    Regards,
    Nagaraju
    , Dec 14, 2013
    #1
    1. Advertising

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

    test.pl


    #!/usr/bin/perl
    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;


    summer.pm


    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>


    spring.pm


    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 test.pl and you are ready to go !
    George Mpouras, Dec 14, 2013
    #2
    1. Advertising

  3. John Black Guest

    In article <>, says...
    > On 14/12/13 08:38, wrote:
    > > i want to know the were the perl modules and packages are in perl

    >
    > 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"
    >


    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
    John Black, Dec 16, 2013
    #3
  4. In article <-september.org>,
    John Black <> wrote:

    > In article <>,
    > says...
    > > On 14/12/13 08:38, wrote:
    > > > i want to know the were the perl modules and packages are in perl

    > >
    > > 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"
    > >

    >
    > 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


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

    dexlabs-ml[17]~ % perl -lE "print for @INC"
    /opt/local/lib/perl5/site_perl/5.12.4/darwin-thread-multi-2level
    /opt/local/lib/perl5/site_perl/5.12.4
    /opt/local/lib/perl5/vendor_perl/5.12.4/darwin-thread-multi-2level
    /opt/local/lib/perl5/vendor_perl/5.12.4
    /opt/local/lib/perl5/5.12.4/darwin-thread-multi-2level
    /opt/local/lib/perl5/5.12.4
    /opt/local/lib/perl5/site_perl
    /opt/local/lib/perl5/vendor_perl
    ..
    dexlabs-ml[18]~ % perl --version

    This is perl 5, version 12, subversion 4 (v5.12.4) built for
    darwin-thread-multi-2level

    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
    the
    Internet, point your browser at http://www.perl.org/, 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]
    Michael Vilain, Dec 16, 2013
    #4
  5. On 2013-12-16 03:11, John Black <> wrote:
    > In article <>, says...
    >> On 14/12/13 08:38, wrote:
    >> > i want to know the were the perl modules and packages are in perl

    >>
    >> 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"
    >>

    >
    > 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.


    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.

    hp


    --
    _ | Peter J. Holzer | Fluch der elektronischen Textverarbeitung:
    |_|_) | | Man feilt solange an seinen Text um, bis
    | | | | die Satzbestandteile des Satzes nicht mehr
    __/ | http://www.hjp.at/ | zusammenpaßt. -- Ralph Babel
    Peter J. Holzer, Dec 16, 2013
    #5
  6. "Peter J. Holzer" <> wrote:
    >>> On 14/12/13 08:38, wrote:
    >>> > i want to know the were the perl modules and packages are in perl
    >>>

    > perl -le 'print for @INC'
    >
    >I'm not sure whether that answers the OP's question, though.


    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
    packages.
    The real question is if this is what the OP meant to ask. But that is
    something only he can answer.

    jue
    Jürgen Exner, Dec 16, 2013
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul  Smith
    Replies:
    0
    Views:
    723
    Paul Smith
    Nov 18, 2003
  2. Dan Richter

    Packages and modules

    Dan Richter, Jul 26, 2005, in forum: Python
    Replies:
    3
    Views:
    270
    Peter Hansen
    Jul 26, 2005
  3. Replies:
    2
    Views:
    247
    Steve Holden
    Nov 10, 2006
  4. David Lyon
    Replies:
    19
    Views:
    561
    David Lyon
    Apr 24, 2009
  5. Ian
    Replies:
    3
    Views:
    159
Loading...

Share This Page