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

Hello Monks, I want to convert strings into expressions which I can use in Perl script to look for pattern match. Assume that there is an input file having multiple text strings. Each string is begins with sub-heading followed by a string. I need to parse this input file and then generate hash array containing key as “sub-heading” and value as “expression”. If I manually convert first sub-heading and followed text into a has entry then it would be…

“Cause” => “^\<\d\>\[\s+[0-9]*\.[0-9]*\]\s+(\w+)\s+Unable\sto\shandle +\skernel\s((\w+)\s)*at\svirtual\s address\s(\w+)”
Input File: --------------------------
Cause: <1>[ 221.631896] c1 Unable to handle kernel NULL pointer dereference +at virtual address 000003d0 Message: <0>[ 221.721038] c1 Kernel panic - not syncing: Fatal exception CPU Info: <4>[ 221.635192] c1 CPU: 1 Not tainted (3.4.5-1368373 #1)
-------------------------- Please help in scripting this. Thanks, Vadiraj

Replies are listed 'Best First'.
Re: Convert strings into Perl expression
by wjw (Priest) on Jun 11, 2014 at 06:58 UTC

    Welcome to PM!

    I think you might find help more forth-coming if you check out a couple of docs here, then edit your question.

    Thought(s) about SOP questions... is a node I wrote to remind myself about how to get a question answered here. It just high-lights a few of the basics to help you get help and has some links in it to more detailed information written by those a lot more articulate than I am, some of whom graciously contributed to the node.

    Take a look at it, then at Markup in the Monastery, modify your post, and I am certain you will get some good advice(but you probably will not get scripting done for you).

    Hope that helps you to help us help you...

    And again, Welcome!

    ...the majority is always wrong, and always the last to know about it...

    Insanity: Doing the same thing over and over again and expecting different results...

    A solution is nothing more than a clearly stated problem...otherwise, the problem is not a problem, it is a facct

Re: Convert strings into Perl expression
by Anonymous Monk on Jun 11, 2014 at 06:59 UTC