Rafael Morales wrote:
Hi list !!!

This is my trouble, I have a file with this output:

[11/14/05 22:52:10:130 GMT] 686b4b72 SystemOut     O POST: 
https://198.104.159.77/ssldocs/ws/xt_vm_transkods.alia?brand=KO-BR&person_id=14560115&password=teatro&trans_id=2&amount=10&trans_date=2005-11-14
 20:52:10&trans_log=113200873013026&tp_Kodes=1
[11/14/05 22:52:10:268 GMT] 686b4b72 SystemOut     O RESP: 
&ia_error=0&vm=60&in_auction=0&pc_count=6&
[11/14/05 22:52:10:293 GMT] 686b4b72 SystemOut     O ZIPCODE:12120000
[11/14/05 22:52:10:309 GMT] 686b4b72 SystemOut     O WS:RedeemCode Params: 
pincode='4DPJQFVCXLRNIA' redeem_date='2005-11-14 10:52:09' person_id='14560115' 
brand='KO-BR' &js_error=0&vm=60&pc_count=6
[11/14/05 22:52:10:377 GMT] 5636cb62 SystemOut     O Algoritmo: H
[11/14/05 22:52:10:378 GMT] 5636cb62 SystemOut     O Semilla del nuevo 
algoritmo:-1


And my match is in last line (the :-1), but I need that line and the two lines 
above. my question is how do I get that two lines above ???

Regards and Thanks a lot !!!


You could for example do that by buffering them. Following example reads from standard input. No that you should replace the regexp by something with more meaning in your context. This application also assumes that there will be at least three lines of input.

my $a=<STDIN>;
chomp $a;
my $b=<STDIN>;
chomp $b;
my $c=<STDIN>;
chomp $c;
while($c !~ /-1$/){
        $a=$b;
        $b=$c;
        $c=<STDIN>;
        chomp $c;
}
if($c =~ /-1$/){        
        print "$a\n$b\n$c\n";
}else{
        print "Not found\n";
}

hth
E.
--
Elie De Brauwer


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to