Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Basic Queries

by Sarat1729 (Sexton)
on Sep 07, 2017 at 08:41 UTC ( [id://1198833]=perlquestion: print w/replies, xml ) Need Help??

Sarat1729 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Guys,

I have few basic queries related to Perl. Can someone help me with the below.

1) What is @INC

2) I am using Strawberry Perl on a Windows machine and in need of installing Catalyst for web development. But, it is throwing an error as lwp failed with code 500 message can't connect to cpan.strawberryperl.com:80. What are the other ways in which I can achieve this.

3) What exactly happens inside when try to install a module from CPAN. If possible end to end process.

Replies are listed 'Best First'.
Re: Basic Queries
by choroba (Cardinal) on Sep 07, 2017 at 09:04 UTC
    1. @INC:

      The array @INC contains the list of places that the do EXPR, require, or use constructs look for their library files. It initially consists of the arguments to any -I command-line switches, followed by the default Perl library, probably /usr/local/lib/perl, followed by ".", to represent the current directory. ("." will not be appended if taint checks are enabled, either by -T or by -t , or if configured not to do so by the -Ddefault_inc_excludes_dot compile time option.) If you need to modify this at runtime, you should use the use lib pragma to get the machine-dependent library properly loaded also:
      use lib '/mypath/libdir/'; use SomeMod;

      You can also insert hooks into the file inclusion system by putting Perl code directly into @INC . Those hooks may be subroutine references, array references or blessed objects. See require for details.

    2. I can connect to the address. Are you behind a proxy? You need to configure your cpan client to use it.

    3. cpan

      Basically, it finds the tarball, downloads it, extracts the files, runs Build.PL or Makefile.PL followed by Build or Make respectively, then it runs tests and finally installs the library if tests are successful. It does the same for all the dependencies first.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
      2. I can connect to the address. Are you behind a proxy? You need to configure your cpan client to use it.

      How can I configure my cpan client. Obliged if it is elaborated.

      3. Basically, it finds the tarball, downloads it, extracts the files, runs Build.PL or Makefile.PL followed by Build or Make respectively, then it runs tests and finally installs the library if tests are successful. It does the same for all the dependencies first.

      Can we make this process happen manually. If so how?

      Thanks in Advance

        Can we make this process happen manually. If so how?
        As hippo said, you can manually install modules. But as you mentioned Catalyst above, you must keep in mind that cpan can automatically follow prerequisites. Manually building and installing all required modules for things like Catalyst, can be a very tedious job.
Re: Basic Queries
by marto (Cardinal) on Sep 07, 2017 at 09:06 UTC

    @INC is an array containing a list of directories perl will search when you ask it to load a module via use or require. perlvar has much more.

    Strawberry ships with cpanm use this to install modules, it's considerably faster than cpan:

    cpanm Catalyst::Devel

    If this fails you may have to configure it to cater for firewalls or special networking considerations. See the cpanm documentation.

    When installing with cpan/cpanm modules and their dependency trees are downloaded, tested and installed. You should be able to cancel the process by pressing ctrl+c.

Re: Basic Queries
by karlgoethebier (Abbot) on Sep 07, 2017 at 09:16 UTC
    "What is @INC?"

    A little complement to the good advice already given: Just take a look at it: perl -E 'say for @INC'.

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1198833]
Approved by marto
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-26 03:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found