Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: perl regex extraction from a large input file

by TJPride (Pilgrim)
on Sep 14, 2013 at 19:05 UTC ( [id://1054128]=note: print w/replies, xml ) Need Help??


in reply to perl regex extraction from a large input file

I have no idea what structure you're trying to achieve here. Assuming you want counts of passed/failed case and req URL's:
use Data::Dumper; use strict; use warnings; my (%counts, $case, $req); while (<DATA>) { chomp; if (m/\Q[Case-Url] - \E(.*)/) { $case = $1; } elsif (m/\Q[Req-URL ] - \E(.*)/) { $req = $1; } if (m/\*\*\*(Passed|Failed)\*\*\*/) { $counts{$1}{'case'}{$case}++; $counts{$1}{'req'}{$req}++; } } print Dumper(\%counts); __DATA__ Execution start time 09/13/2013 02:43:55 pm [Case-Url] - www.google.com [Req-URL ] - www.qtp.com ***Passed*** __________________________________________________________ [Case-Url] - www.yahoo.com [Req-URL ] - www.msn.com ***Passed*** ___________________________________________________________ [Case-Url] - www.google.com [Req-URL ] - www.qtp.com ***Failed***
Output:
$VAR1 = { 'Passed' => { 'req' => { 'www.qtp.com' => 1, 'www.msn.com' => 1 }, 'case' => { 'www.google.com' => 1, 'www.yahoo.com' => 1 } }, 'Failed' => { 'req' => { 'www.qtp.com' => 1 }, 'case' => { 'www.google.com' => 1 } } };

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1054128]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (11)
As of 2024-04-23 21:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found