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.
In reply to first two words-pattern matching by shamala
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |