Gunnar Hjalmarsson wrote: >Use map() together with split() to populate a hash.
Like this... my %urls = map { split(' ', $_) } <LINKS>; if this is correct, can someone hint to me how I am supposed to incorporate this into my foreach statement. use strict; use LWP::Simple; my $file = "/Program Files/OptiPerl/links.out"; open (LINKS, $file) or die "Can't open $file: $!"; # ------------ slurp the file ------------------------- # my @urls = <LINKS>; my %urls = map { split(' ', $_) } <LINKS>; # ----------- remove line endings --------------------- chomp %urls; # --------- check each url in file -------------------- foreach my $url (@urls) { print "$url\n"; my ($type) = head($url); # ---------- broken links go into bad.txt ------------- unless (defined $type) { open (BAD, ">>bad.txt"); print (BAD "$url\n"); # print "Couldn't get $url\n"; next; } # --------- good links go into good.txt --------------- if ($type) { open (GOOD, ">>good.txt"); print (GOOD "$url\n"); # print "Got it! \n$url\n"; } } # --------- close all file handles -------------------- close LINKS; close GOOD; close BAD; I changed @urls to %urls and the script actually gave me what I was trying to accomplish... but I would rather know the correct way. Thank you for any help. Brian Volk -----Original Message----- From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED] Sent: Friday, July 16, 2004 4:39 PM To: [EMAIL PROTECTED] Subject: Re: keeping the file name while checking w/ LWP Brian Volk wrote: > I have a file that contains the file name and the url. I need to > separate the url so I can use LWP::Simple; to check the link, > however, I need to keep the file name in tact so I can trace it > back to my website. Anyone have any suggestions? Use map() together with split() to populate a hash. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>