Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: trim header lines in files

by rjt (Curate)
on Aug 05, 2013 at 13:07 UTC ( [id://1047907]=note: print w/replies, xml ) Need Help??


in reply to trim header lines in files

You can just chop off the pipe and anything thereafter before you print:

while (<>) { s/^>.+?\K\|.*$//; print; }

If the non-matching lines are quite long but the "or1" tags are short, it will speed things up to specify a quantifier on the substitution (Edit: disregard this optimization if non-matching lines never start with '>'):

    s/^>.{1,10}\K\|.*$//; # Tag is between 1..10 chars
use strict; use warnings; omitted for brevity.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-25 19:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found