Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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"; }

In reply to Re: concatenating elements of an array in twos by tangent
in thread concatenating elements of an array in twos by Sandy_Bio_Perl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-24 00:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found