On 11/16/05, Rafael Morales <[EMAIL PROTECTED]> 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 !!!
>
Here's one way:
#!/usr/bin/perl
use warnings;
use strict;
my $data;
{
local $/;
$data = <DATA>;
}
my @matches = ($data =~ m/((?:.+?\n){2}.+:-1\n)/g);
foreach (@matches) {
my @lines = split /\n/;
print map {"$_\n"} @lines, "\n";
}
__END__
[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 1\
0: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
( '\' in data indicates long lines were broken for the email.)
Of course, if your data set is horribly large, you may not want to slurp it.
HTH
-- jay
--------------------------------------------------
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential
daggerquill [at] gmail [dot] com
http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org
values of β will give rise to dom!