Well, without indentation your code is difficult to read. Try wrapping it in <c></c> tags and format it to be readable by those unfamiliar with it. From a quick glance there are many errors (such as putting a \n after the semi-colon. Using warnings will catch that.)
That being said, try (actually, don't try it -- just get inspiration from it :P)
#!/usr/bin/perl
use warnings;
use strict;
my @final; # Joined lines will be in here
open(URLS, '<', 'urls.txt') or die $!; # I can never remember if < is
+read
chomp(my @urls = <URLS>); # Every line of URLS is a different element
+in @urls
close URLS;
open(CODES, '<', 'data.txt') or die $!;
chomp(my @codes = <CODES>);
close CODES;
foreach my $url (@urls) { # For every element (line) in @urls,
foreach my $code (@codes) { # and for every element in @codes,
push @final, $url$code; # append the two and push it into @fin
+al
}
}
The first three lines should be in all your Perl programs. Using warnings will catch a lot of stupid mistakes you will make and using strictures will keep you from making a lot of stupid mistakes. I think the rest of the code is self explanatory.
Updated with more comments.
Update 2: Ikegami reminded me (thanks ikegami :D) that you must chomp() each element of the arrays before you push it into @final to remove the newline at the end. I'll update my code to show this soon. Done (with inspiration from kyle :P).
And you didn't even know bears could type.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.