Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

deletion of one line of a particula pattern

by drock (Beadle)
on Aug 23, 2004 at 19:41 UTC ( #385198=perlquestion: print w/replies, xml ) Need Help??

drock has asked for the wisdom of the Perl Monks concerning the following question:

All, I have tried to delete every line that has the string ID:a-z-0-9 or ID:* and cannot get it to work. Any help would be much appreciated! Here is the data file
ID:8F03F770.3E6A0B05.00000200.5E0263D7, (E00123), (E00540), (E00216), (E00313), (E00486), (E00112), (E00822), (E00792), (E00774), (E00623), (E00022), (E00188), (E00017), (E00075), (E00055), ID:500460E9.BB25AD46.00000200.3E044511,
I do not want the string ID:* and ideally only Exxxx w.out the ( ) or , thank you!

Replies are listed 'Best First'.
Re: deletion of one line of a particula pattern
by insensate (Hermit) on Aug 23, 2004 at 19:45 UTC
    while(<DATA>){ print "$1$/" if /\((E\d+)/; } __DATA__ ID:8F03F770.3E6A0B05.00000200.5E0263D7, (E00123), (E00540), (E00216), (E00313), (E00486), (E00112), (E00822), (E00792), (E00774), (E00623), (E00022), (E00188), (E00017), (E00075), (E00055), ID:500460E9.BB25AD46.00000200.3E044511,
    Should do the trick...assuming all your desired values match E then a number of digits....
      awesome... I wish I was better at reg exps. my only complaint is the output looks like:
      (E1234), E1234 (E4545), E4545
      instead of just
      Exxxx Exxxx Exxxx
        That's odd... can you provide the snippet of code that's producing that output?
Re: deletion of one line of a particula pattern
by ccn (Vicar) on Aug 23, 2004 at 19:56 UTC

    perl -ne "print unless /ID:/" datafile

    update: perl -i.bak -lne "print $1 if /\((E\d+)\)/" datafile

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://385198]
Approved by ysth
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2023-06-05 10:43 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (24 votes). Check out past polls.