Where you have
if ($sid eq $sidtwobinder[0])
you are not getting a match because $sid is "1" and $sidtwobinder[0] is "sid 1" (note the two spaces between sid and 1). You could change your @sid array to contain the whole text. I don't know how big your dataset is but it is inefficient to loop through @unpairedSidBinder inside the outer loop. You could split it into two stages, saving the matches in a hash of arrays - something like:
my @sid = ('sid 1','sid 2','sid 7','sid 9');
my %hoa;
foreach my $el (@unpairedSidBinder){
my ( $key, $data ) = split /\|/,$el;
push( @{ $hoa{$key} }, $data );
}
foreach my $key (@sid) {
my $ary = $hoa{$key} or next;
my $temp = join(" ", @$ary );
print "$key|$temp\n";
}
-
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.
|