Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Regex random values pattern match and code efficiency

by Mark.Allan (Sexton)
on Sep 12, 2013 at 18:04 UTC ( [id://1053780]=note: print w/replies, xml ) Need Help??


in reply to Re: Regex random values pattern match and code efficiency
in thread Regex random values pattern match and code efficiency

Yes, extract values which are in braces only BUT the same values will not be there every time, for example, another file will only contain the following

DEPLOY_PARAMS=$DOMAIN{HOST},$DOMAIN{IP}

Or

DEPLOY_PARAMS=$DOMAIN{HOST}

For example, the values could change in every file so its not static mapping

  • Comment on Re^2: Regex random values pattern match and code efficiency

Replies are listed 'Best First'.
Re^3: Regex random values pattern match and code efficiency
by hdb (Monsignor) on Sep 12, 2013 at 18:07 UTC

    Well, I encourage you to run my proposed code on all kinds of test data to see how it fares. You might also try to understand how it works to see that it does not care what exactly there is. As you will see there is no sign of a static mapping.

    One thing I would propose is to add a filter for lines without equal sign to make it more robust:

    my %h = map {my($k, $v)=/^(.*?)=(.*)/; $v=[ $v=~/{(.+?)}/g ] if $v=~/} +/; $k=>$v } grep {/=/} <DATA>;

Log In?
Username:
Password:

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

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

    No recent polls found