perlquestion
Jaganath
Hi folks - I'm a perl FNG and I have a question about joining and outputing arrays.
I have two arrays (lines read in from txt files and split on \n).
What I need to do is join them, but in itterations.<br />
i.e., the first array contains urls, say<br /> http://www.something.com/blah.aspx?code= <br />and<br />
http://www.somethingelse.com/stuff.aspx?thing=<br /><br />
The second array contains product codes, say<br />
375035304<br />
564564774<br />
346464646<br />
<br />
I need to end up with an array containing
an entry for each url/code combination -i.e<br /><br />
http://www.something.com/blah.aspx?code=375035304<br />
http://www.something.com/blah.aspx?code=564564774<br />
http://www.something.com/blah.aspx?code=346464646<br />
http://www.somethingelse.com/stuff.aspx?thing=375035304<br />
http://www.somethingelse.com/stuff.aspx?thing=564564774<br />
http://www.somethingelse.com/stuff.aspx?thing=346464646<br /><br />
So far nothing I've tried works (I'm only about 12 hours into my perl voyage so please forgive my ignorance :0)<br /><br />
Any help would be very welcome - here's my code so far:<br />
#!/usr/bin/perl<br /><br />
#open and assign urls file<br />
open (URLS, "urls.txt") || die("Couldn't open file!");<br />
@raw_urls=<URLS>;<br />
close(URLS);<br /><br />
#open and assign isbn/prod code file<br />
open (CODES, "data.txt") || die("Couldn't open file!");<br />
@raw_codes=<CODES>;<br />
close(CODES);<br /><br />
# loop through urls, split out and dump in array<br />
foreach $urls (@raw_urls)<br /><br />
{<br />
(@url)=split(\n, $urls);<br />
print @url; \n #test output<br />
}<br />
# loop through codes, split out and dump in array<br />
foreach $codes (@raw_codes)<br />
{<br />
(@code)=split(\n, $codes);<br />
print @code; \n #test output<br />
<br />
}