in reply to Re: awk 2 perl oneliner
in thread awk 2 perl oneliner
Thanks a lot, your script is great. Your solution is also a lot faster than the awk oneliner. I modified it a bit to fit my real data.
The only prob I have now is, when applied to my real data a ">" sign is missing at the beginning (which I got around with a print before the second while loop) and one is too much at the end.#!/usr/bin/perl # create names lookup table from first file while (<>) { #get rid of newline in name because there might be #something like >name1\stext\n in the second file chomp; $names{$_} = 1; last if eof; } $/ = "\n>"; # set input record separator # scan second file print ">"; # print first ">" that would be missing while (<>) { print if /^>?([\w\d]+)/ && $names{$1}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: awk 2 perl oneliner
by almut (Canon) on Mar 06, 2010 at 20:16 UTC | |
by space_agent (Acolyte) on Mar 07, 2010 at 12:57 UTC |