shamala has asked for the wisdom of the Perl Monks concerning the following question:
I want only the first two words(for ex:ctx ctx_53) from each of the lines that begin with the similar kind of words like the third line has - plsql tkmain_ps4 and i want this to be matched. I have written the following but isnt working...could any of you please help...i am a begginner at perl.<first line> :ctx ctx_3 ctx_3 040425 0 0 +07-May-2004 03:29 07-May-2004 03:29 0.00 hobbit + N/A failed PLE-QA N/A 0 <second line> Not Published 466008691 <third line>plsql tkmain_ps4 tkmain_ps4 040425 0 + 0 07-May-2004 03:29 07-May-2004 03:29 0.00 + hobbit N/A failed PLE-QA N/A 0 <...> Not Published 466008691 <nth line>plsql tkmain_pu3 tkmain_pu3 040425 0 + 0 07-May-2004 03:29 07-May-2004 03:29 0.00 h +obbit N/A failed PLE-QA N/A 0 Not Published 466008691 rdbms tkmain_2n1 tkmain_2n1 040425 0 0 + 07-May-2004 01:37 07-May-2004 01:37 0.00 hobbit + N/A failed PLE-QA N/A 0 Not Published 465894765
Thanks ppl#! /usr/local/bin/perl #use strict; open(rerun,"rerunlrg") while(my $pattern=<rerun>){ if(my $pattern=~ m/^(\w\s+\w\s).*?/){ print "matched\n"; print "$1\n"; }
Edited by Chady -- added code tags around file contents.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: first two words-pattern matching
by davido (Cardinal) on May 12, 2004 at 06:14 UTC | |
|
Re: first two words-pattern matching
by matija (Priest) on May 12, 2004 at 06:19 UTC | |
|
Re: first two words-pattern matching
by TilRMan (Friar) on May 12, 2004 at 06:29 UTC | |
by shamala (Acolyte) on May 12, 2004 at 06:46 UTC | |
|
Re: first two words-pattern matching
by saskaqueer (Friar) on May 12, 2004 at 06:18 UTC | |
|
Re: first two words-pattern matching
by snadra (Scribe) on May 12, 2004 at 10:52 UTC |