I\'m a bit new to programming and I\'m having some trouble writing a Perl script that will grab all the images from a webpage and save them in a specified directory.
Her
That's a standard error when you haven't installed the module. Image::Grab does not come with perl. There are lots of perl modules available on something called cpan, for instance:
http://search.cpan.org/~mahex/Image-Grab-1.4.2/lib/Image/Grab.pod.
Modules are libraries of functions that someone has written in perl and made available for your use.
Now, you have to figure out how to install modules. See if this works:
$ perl -MCPAN -e shell
-M => Use the module specified, in this case CPAN(comes with perl)
-e => execute the following perl code, in this case the function shell().
then
cpan> install Image::Grab.
The first time you do that, you'll have to answer a lot of questions.
Once you are done:
cpan> q ('q' is for quit)
Response to comment:
1) Try updating your CPAN module:
cpan> install CPAN
cpan> reload cpan
then:
cpan> install Image::Grab
Installing from source is fine, but if you can get cpan to work, then it takes care of downloading all the dependencies, so it is hassle free. I just used cpan to download Image::Grab, and I got no errors. It has no dependencies that need to be downloaded.
2) What is the output of:
$ perl --version (it looks like you are using perl 5.10.1)
Also, at the bottom of your question add the entire output from your cpan attempt.
3) Try installing another module, like:
http://search.cpan.org/~rehsack/List-MoreUtils-0.402/lib/List/MoreUtils.pm
I noticed you said you installed the module using CPAN. This would lead me to glean that you're running on a linux operating system, and you just kept pressing the 'enter' key every time the installation script asked you a question, optimistically believing everything would work out, just like in the movies.
If you'd read a little closer you probably would have noticed all kinds of issues with the installation.
I did the same thing yesterday, because I didn't want to go through all the trouble of solving dependencies. And incidentally, I was using CPAN. I'm not sure what CPAN stands for, but yesterday it most definitely didn't stand for Certifiably Perfect Automatic NichePerlModuleInstaller.
Way too often there's no Perl::EasyButton. Sometimes you have to roll up your sleeves up and start w-geting tar.gzs and installing them, only to find out you need other tar.gzs, only to find out you need more tar.gzs, until one day you're looking back and wondering where your life went.
Unless you can get CPAN to work. Then you just have to sit in front of your putty terminal like a monkey pressing the enter key every time it asks you a question and suggests an answer. And if you're lucky, after you've pressed 'enter' 1837 times, the module you need to use will be installed and functional.
I might suggest a different module or approach altogether, where you're looking for an easy way to grab images off the internet. If you're into Perl for the longhaul, I say roll your sleeves up and get dirty. If you give me a URL for an image, I can write the code from scratch to have that thing downloaded in a matter of a few minutes. And then I can reuse that code as many times as I want to download more images. And before long I can fill a hard drive up with images I downloaded from that original code.
You need to get yourself to that point. Or you need to look for a canned solution that can be used by the masses, and take your place among them (the masses).
Or, you could google the exact problem you're having when you're running the installation on CPAN and figure out what you're doing wrong. That's an option.
And there are probably a couple more options. Hopefully you'll come up with a good one.
Good luck!