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>;