Hi monks,
i have a file whose contents are as below:
<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
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.
#! /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";
}
Thanks ppl
Edited by Chady -- added code tags around file contents.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|