I'm writing twin programs; one to store the source codes of a list of websites, and the other to use the stored info to tell me whether or not the website has been updated since last stored. I can't get the storing program to work, though, and can't figure out why.
use strict;
use warnings;
use LWP::Simple;
my @list;
my $source;
my $i;
my $file="C:/Documents and Settings/Dad/Desktop/url checker.txt";
open FILE, "<$file";
while(<FILE>){
push @list, $_;
}
close FILE;
my $length=length(@list);
for($i=0; $i<=$length; $i++){
my $j=$i+1;
$source=get($list[$i]);
open LOG, ">C:/Documents and Settings/Dad/Desktop/Websites/Website
+ Source[$j].txt";
print LOG $source;
close LOG;
}
I get the error "can't print on closed filehandle..."
Thanks in advanced.
-edit
Now it works fine except for that it only logs the sources of 3 websites, out of a list of 13.
use strict;
use warnings;
use LWP::Simple;
my @list;
my $source;
my $i;
my $file="C:/Documents and Settings/Dad/Desktop/url checker.txt";
open FILE, "<$file" || die "Can't open the list of urls! \n";
while(<FILE>){
push @list, $_;
}
close FILE;
my $length=length(@list);
for($i=0; $i<=$length; $i++){
my $j=$i+1;
$source=get($list[$i]);
open LOG, ">C:/Documents and Settings/Dad/Desktop/Websites/Website
+ Source $j.txt" || die "Can't open website sources.txt: $!\n";
print LOG $source;
close LOG;
}
Any ideas?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.