Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Universal Require

by simonodell1 (Novice)
on Apr 13, 2007 at 08:02 UTC ( [id://609843]=perlquestion: print w/replies, xml ) Need Help??

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

$attitude = "humble"; require PerlGOD::Knowledge; print "master, I beesech your wisdom";

I need a little help using Universal::Require.

here is a snippet of code which works...

my $url = 'http://www.perl.com'; use LWP::Simple; my $content = get $url; die "Couldn't get $url" unless defined $content; print "retrieved, $content";

I tried to use the LWP::Simple module through universal require thusly;

require UNIVERSAL::require; my $url = 'http://www.perl.com'; my $module = 'LWP::Simple'; my $return_val = $module->use or die $@; my $content = get $url; die "Couldn't get $url" unless defined $content; print "retrieved :: $content";

But it doesnt work :/ erm... what am i doing wrong?

for (1..*) { $thank = "PerlGOD"; }

Replies are listed 'Best First'.
Re: Universal Require
by gloryhack (Deacon) on Apr 13, 2007 at 08:54 UTC

    If you haven't tried it yet, add this to the top of your code:

    use strict; use diagnostics;

    What you should then see when you run your code:

    Can't locate UNIVERSAL/require.pm in @INC (@INC contains: ... BEGIN failed--compilation aborted at wtf.pl line 9 (#1) (F) You said to do (or require, or use) a file that couldn't be found. Perl looks for the file in all the locations mentioned in @ +INC, unless the file name included the full path to the file. Perhaps +you need to set the PERL5LIB or PERL5OPT environment variable to say w +here the extra library is, or maybe the script needs to add the library + name to @INC. Or maybe you just misspelled the name of the file. See perlfunc/require and lib.

    perl will help you, if you'll let it. It will take some time to get your head wrapped around the warnings so you'll know what they're telling you/what to look for. Once you've got a good feel for it, you can keep the screen clutter down by switching from the diagnostics pragma to the warnings pragma.

    Good on ya for the effort!

      thanks gh, i'll bear that in mind for future ref..

      as for the prob i got it working, all it needed was ;

      my $content = get $url; changing to my $content = get($url);

      doh!

      aXML now has a new plugin called <geturl> :) :)

        as for the prob i got it working, all it needed was ;
        my $content = get $url; changing to my $content = get($url);

        Really? I find that hard to believe:

        Update: I stand corrected. Had not really understood what the issue was about, out of only reading superficially. Shame on me! Rest of post fundamentally irrelevant now.


        and

Log In?
Username:
Password:

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

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

    No recent polls found