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

Please help, I'm totally a novice to all this stuff. I just got help with a script and they told me to use a certain module. I have never even heard of a module before, much less implement it. Do I just stick it anywhere I want to check an email address?
Email::Valid
like that? Thanks in advance

Replies are listed 'Best First'.
Re: How do I use a module?
by chromatic (Archbishop) on Apr 16, 2000 at 00:17 UTC
Re: How do I use a module?
by btrott (Parson) on Apr 15, 2000 at 22:38 UTC
    @INC is the array of directories where Perl searches for modules; usually it's set to things like
    /usr/local/lib/perl5/site_perl /usr/local/lib/perl5 .
    etc. Yours, apparently, is set only to ".", which seems a bit odd. I believe the basic @INC is set when Perl is compiled, although you can certainly modify it in your own scripts or through the environment.

    So it seems that either your Perl has been compiled incorrectly, or this was done intentionally. Are you on a host like Tripod? I think they only let you use modules in your current directory. They have certain modules that they let you install.

    If you're not on a restrictive host :), you can modify your @INC by setting the PERL5LIB environment variable, or by using the "use lib" statement in your script:

    use lib '/home/foo/my_perl_modules';
    and so on.
RE: How do I use a module?
by little_mistress (Monk) on Apr 17, 2000 at 05:12 UTC
    or you could try this:

    sub BEGIN { push(@INC, "/try/looking/here"); #and other amazing tricks }

    what the "BEGIN" subrouteen does is allow you to execute code BEFORE the script is compiled. This can allow you to do any pre-initialization you need to do for the script.

    little_mistress@mainhall.com

Re: How do I use a module?
by BBQ (Curate) on Apr 18, 2000 at 05:38 UTC
    Ooooor as an alternative to CGI.pm, you could use cgi-lib.pl (which is what I have used since the time when the dinosaurs roamed the earth), if you only what to parse your query data.

    A safe example would be:
    eval { require 'cgi-lib.pl'; }; if ($@) { print qq{Content-type: text/plain\n\n}; print qq{ I've goofed trying to find cgi-lib.pl! $@ }; }
    At least that way you keep the script from outputting the ugly 500's back at ya (which, by the way, can also be acomplished by use CGI::Carp (fatalsToBrowser); if ya didn't have the problem in the 1st place).

    There's more than 1 way to do it!