Am I getting close...? my $file = "/Program Files/OptiPerl/urls.txt"; open (LINKS, $file) or die "Can't open $file: $!";
chomp (@url = read(LINKS, $url, 100)); Thanks for your help! Brian -----Original Message----- From: James Edward Gray II [mailto:[EMAIL PROTECTED] Sent: Thursday, July 15, 2004 10:10 AM To: Brian Volk Cc: Beginners (E-mail) Subject: Re: foreach (from a file) On Jul 15, 2004, at 9:40 AM, Brian Volk wrote: > Hi All, > > If I have a file, /usr/bin/my_urls.txt which contain... urls... :-) > one on > each line. Can I read these into a foreach statement instead of > listing > them individually? I think I need to use a filehandle to open the > file and > then send that to the @ ... right? Exactly, right. I'll give the steps: 1. open() your file. Remember to check if it succeeds! 2. Read line by line, chomp()ing line endings and adding them to an array. 3. close() fiie and use array in foreach loop. Just shout if you need more help... James -- 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>