Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How do I use the map command for this?

by tybalt89 (Monsignor)
on Jun 19, 2022 at 17:13 UTC ( [id://11144856]=note: print w/replies, xml ) Need Help??


in reply to How do I use the map command for this?

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11144847 use warnings; my %res; /(id\d+)(.*)/s and push @{ $res{$2} }, $1 for split />/, join '', <DAT +A>; for ( sort keys %res ) { local $" = '|'; print ">@{$res{$_}}$_"; } __DATA__ >id1|Q51487|P-474-4|86-98,113-126,297-310,322-335 CSLIPDYQRPEAPVAAAYPQGQAYGQNTGAAAVPAADIGWREFFRDPQLQQLIGVALE >id2|Q51487|P-474-4|86-98,113-126,297-310,322-335 CSLIPDYQRPEAPVAAAYPQGQAYGQNTGAAAVPAADIGWREFFRDPQLQQLIGVALE >id3|Q51487|P-474-4|86-98,113-126,297-310,322-335 CSLIPDYQRPEAPVAAAYPQGQAYGQNTGAAAVPAADIGWREFFRDPQLQQLIGVALE >id4|Q51487|P-474-4|86-98,113-126,297-310,322-335 alt CSLIPDYQRPEAPVAAAYPQGQAYGQNTGAAAVPAADIGWREFFRDPQLQQLIGVALE >id5|Q51487|P-474-4|86-98,113-126,297-310,322-335 alt CSLIPDYQRPEAPVAAAYPQGQAYGQNTGAAAVPAADIGWREFFRDPQLQQLIGVALE

Outputs:

>id1|id2|id3|Q51487|P-474-4|86-98,113-126,297-310,322-335 CSLIPDYQRPEAPVAAAYPQGQAYGQNTGAAAVPAADIGWREFFRDPQLQQLIGVALE >id4|id5|Q51487|P-474-4|86-98,113-126,297-310,322-335 alt CSLIPDYQRPEAPVAAAYPQGQAYGQNTGAAAVPAADIGWREFFRDPQLQQLIGVALEc>

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11144856]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found