Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Using www::curl

by barrycarlyon (Beadle)
on Apr 19, 2007 at 11:54 UTC ( #610930=perlquestion: print w/ replies, xml ) Need Help??
barrycarlyon has asked for the wisdom of the Perl Monks concerning the following question:

Greetings

Im trying to write a perl script, which takes data from a database, and uses curl to interact with the Twitter API in order to update my status. Using CRON to trigger it.

This is my first attempt at a non website-outputting script

So Currently i Have:

################################################################# # # # LSRfm.com Twitter Updater # # (c) Barry Carlyon 2006 # # # ################################################################# #!/usr/bin/perl package CRON::Twitter::Twitter; use lib '/home/lsrfm/webs/www.lsrfm.com/perllib/'; use strict; use warnings; use WWW::Curl; use WWW::Curl::Easy; #use Class::Date; twitter(); sub twitter { print "Twitter time"; } 1;

However i get:

Can't locate loadable object for module WWW::Curl in @INC (@INC contai +ns: /home/lsrfm/webs/www.lsrfm.com/perllib/ /home/lsrfm/perllib /usr/ +local/lib/perl5/site_perl/5.8.5/mach /usr/local/lib/perl5/site_perl/5 +.8.5 /usr/local/lib/perl5/site_perl/5.6.1 /usr/local/lib/perl5/site_p +erl /usr/local/lib/perl5/5.8.5/BSDPAN /usr/local/lib/perl5/5.8.5/mach + /usr/local/lib/perl5/5.8.5 .) at Twitter.pm line 16 Compilation failed in require at Twitter.pm line 16. BEGIN failed--compilation aborted at Twitter.pm line 16.

I have downloaded and make'd WWW::Curl, and it is in the library location i have specified

Also how do i make a database connection?

As i tried including the database files, and it doesnt work, mainly becuase where the script runs, the perl libs are not installed at root, though are avaiable for access if quired for the web...

Update: forgot to mention, the system im on allows make'ing but not install'ing

Final Update - Turns out it was a dodgy install, and the paths listed done exists as the mach bits are at the directory i cant access/edit/install to. Anywho the net::twitter module does its job, i just need to cron it in, but i cant edit my crontab, as my server provider is being funny lol

Thanks for all the help :-)

Final Final Update

All working check twitter.com/lsrfm_com

Barry Carlyon barry@barrycarlyon.co.uk

Comment on Using www::curl
Select or Download Code
Re: Using www::curl
by davidrw (Prior) on Apr 19, 2007 at 12:26 UTC
Re: Using www::curl
by adrianh (Chancellor) on Apr 19, 2007 at 12:33 UTC

      Got net::twitter then json::any now for that im getting,

      Couldn't find a JSON Package.
      Got JSON no help

      Update: fixed

      Barry Carlyon barry@barrycarlyon.co.uk
Re: Using www::curl
by derby (Abbot) on Apr 19, 2007 at 12:55 UTC

    Read the error message carefully ... the interpreter is finding WWW::Curl ... it cannot load one of it's XS shared objects. Look for a Curl.so in your @INC and, if on linux, do an ldd to see if all it's shared lib dependencies can be resolved. Sounds like a broken install of WWW::Curl.

    -derby
Re: Using www::curl
by almut (Canon) on Apr 19, 2007 at 14:34 UTC
    Can't locate loadable object for module WWW::Curl ... (...)
    I have downloaded and make'd WWW::Curl, and it is in the library location i have specified

    Some background info, as this is a commonly occurring problem when installing modules into a private location:  There are two types of modules: architeture-independent (pure Perl) and architecture-specific ones (XS modules, i.e. a binding to some C library (typically in the form of a shared object (.so) file).

    WWW::Curl is an architecture-specific one. This means you need to take a bit more care, if you manually build and install the files. The easiest way to set things up properly in some private lib dir is to put all files into a directory structure that Perl normally expects to find (I say normally, because there are of course ways to tweak things...).

    If you add an additional lib path with use lib '/path/to/perllib';, there should be two directory branches - you guessed it: an architecture-independent one, and an architecture-specific one. The former is the lib path as specified (i.e. /path/to/perllib/), and the latter is a subdirectory therein: /path/to/perllib/arch/, where "arch" is the actual architecture name, e.g. something like x86_64-linux-thread-multi1. Architecture-specific modules consist of two parts, the .pm file (Perl code), and the .so file (actual XS/C binding; binary, compiled code). The .so files go below an arch/auto subdirectory. So, for WWW::Curl you should have a structure something like this:

    $ find /home/lsrfm/webs/www.lsrfm.com/perllib /home/lsrfm/webs/www.lsrfm.com/perllib /home/lsrfm/webs/www.lsrfm.com/perllib/mach /home/lsrfm/webs/www.lsrfm.com/perllib/mach/auto /home/lsrfm/webs/www.lsrfm.com/perllib/mach/auto/WWW /home/lsrfm/webs/www.lsrfm.com/perllib/mach/auto/WWW/Curl /home/lsrfm/webs/www.lsrfm.com/perllib/mach/auto/WWW/Curl/Curl.bs /home/lsrfm/webs/www.lsrfm.com/perllib/mach/auto/WWW/Curl/Curl.so /home/lsrfm/webs/www.lsrfm.com/perllib/mach/auto/WWW/Curl/.exists /home/lsrfm/webs/www.lsrfm.com/perllib/mach/WWW /home/lsrfm/webs/www.lsrfm.com/perllib/mach/WWW/Curl /home/lsrfm/webs/www.lsrfm.com/perllib/mach/WWW/Curl/Multi.pm /home/lsrfm/webs/www.lsrfm.com/perllib/mach/WWW/Curl/Form.pm /home/lsrfm/webs/www.lsrfm.com/perllib/mach/WWW/Curl/Easy.pm /home/lsrfm/webs/www.lsrfm.com/perllib/mach/WWW/Curl.pm

    The lib pragma automatically adds the appropriate architecture-specific subdirectory to @INC, in addition to the toplevel lib dir you specify. From the docs:

    For each directory in LIST (called $dir here) the lib module also checks to see if a directory called $dir/$archname/auto exists. If so the $dir/$archname directory is assumed to be a corresponding architecture specific directory and is added to @INC in front of $dir.

    You can verify this doing

    perl -Mlib=/home/lsrfm/webs/www.lsrfm.com/perllib -V

    Should produce, in the @INC section of the output (and if there is an mach/auto directory):

    @INC: /home/lsrfm/webs/www.lsrfm.com/perllib/mach /home/lsrfm/webs/www.lsrfm.com/perllib (...)

    ___

    1  In your case this seems to be mach (kind of generic, but why not :) -- In case of doubt you can ask Perl: perl -V | grep archname (capital V, btw). Look for archname=...

    Update: or even shorter (thanks, Corion :)

    perl -V:archname

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2014-07-31 00:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (242 votes), past polls