Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
"Is hashes the way to go?"

Your choice of data structure will depend on a number of factors, such as how you want to store and retrieve the structure, how you want to access the data in the structure, and so on. Have a read of "Perl Data Structures Cookbook" to get an idea of what's available.

Here's one possible way:

#!/usr/bin/env perl use strict; use warnings; my %data; { local $/ = "\n>"; while (<DATA>) { $_ = substr $_, 1 if $. == 1; my ($ids, $seq, $lab) = split /\n/; my ($id1, $id2) = split /[|]/, $ids; push @{$data{"$id2-$seq"}}, [$id1, $lab]; } } # For DEMO use Data::Dump; dd \%data; __DATA__ >4kt0_M|P72986 MALSDTQILAALVVALLPAFLAFRLSTELYK iiiiiiiiiMMMMMMMMMMMMMMMMMIIIII >6uzv_m|P72986 MALSDTQILAALVVALLPAFLAFRLSTELYK iiiiiiiiiiiiMMMMMMMMMMMMMMMMMII >5oy0_m|P72986 MALSDTQILAALVVALLPAFLAFRLSTELYK iiiiiiiiiMMMMMMMMMMMMMMMMMIIIII >6hqb_M|P72986 MALSDTQILAALVVALLPAFLAFRLSTELYK iiiiiiiiiiiMMMMMMMMMMMMMMIIIIII


{ "P72986-MALSDTQILAALVVALLPAFLAFRLSTELYK" => [ ["4kt0_M", "iiiiiiiiiMMMMMMMMMMMMMMMMMIIIII"], ["6uzv_m", "iiiiiiiiiiiiMMMMMMMMMMMMMMMMMII"], ["5oy0_m", "iiiiiiiiiMMMMMMMMMMMMMMMMMIIIII"], ["6hqb_M", "iiiiiiiiiiiMMMMMMMMMMMMMMIIIIII"], ], }

— Ken

In reply to Re: How to make unique entries by kcott
in thread How to make unique entries by Anonymous Monk

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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-15 14:44 GMT
Find Nodes?
    Voting Booth?

    No recent polls found