Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Log Parsing

by piyushmnnit06 (Novice)
on Mar 20, 2017 at 11:13 UTC ( #1185247=perlquestion: print w/replies, xml ) Need Help??

piyushmnnit06 has asked for the wisdom of the Perl Monks concerning the following question:

In below log line I want to capture all Successful child runId in a array and will use that for further purpose.no of children varies in my case i.e in below example there are 10 and they may vary case by case. 10 children loaded for parentId=8305 Loaded {child runId vs completion type}: {8316-SUCCESSFUL}{8317-SUCCESSFUL}{8318-SUCCESSFUL}{8319-SUCCESSFUL}{8320-SUCCESSFUL}{8321-SUCCESSFUL}{8322-SUCCESSFUL}{8323-SUCCESSFUL}{8324-SUCCESSFUL}{8325-SUCCESSFUL}

Replies are listed 'Best First'.
Re: Log Parsing
by 1nickt (Abbot) on Mar 20, 2017 at 12:18 UTC

    Your question is not clear. Your post is unformatted. Your code is not separated from your question. How shall the monks assist you when you present them with a dog's breakfast like this?

    To the right of this you will see a menu. It contains links, some of them to pages giving guidance to newcomers here. Please respect the place and read and follow the guidelines. I promise you that if you do, you will get more and better help.

    Is your input an array of anonymous hashes? Do you know what that means? How would we know, since you don't show real code, nor what you'd like your output to be? If it is, maybe something like the following would help. This will produce a new hash keyed by logID, with the value of each key being an array of runIDs.

    my %child_run_id_map = (); for my $log_entry ( @log_entries ) { my $log_id = $1 if $log_entry->{'logId'} =~ m/([^\.]+)/; push @{ $child_run_id_map{ $log_id } }, $log_entry->{'runId'} if $ +log_id; }

    Hope this helps! (but I'm just guessing)


    The way forward always starts with a minimal test.
Re: Log Parsing
by GotToBTru (Prior) on Mar 21, 2017 at 12:25 UTC

    Help us help you. What code do you have so far? Check out tutorials here, and the Perl documentation.

    • You'll almost certainly need open to open the log files to read them.
    • the while loop is very commonly used to read lines from a file one at a time.
    • regular expressions will help you pull out the information you need from the lines in the log
    But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)

Re: Log Parsing
by Laurent_R (Canon) on Mar 20, 2017 at 18:04 UTC
    Please use <code> and </code> tags for your code snippets and data samples.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1185247]
Approved by 1nickt
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2021-05-15 09:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (150 votes). Check out past polls.

    Notices?