in reply to Regex random values pattern match and code efficiency
Trying to understand your question: In the first post you were told how to find the right hand side of DEPLOY_PARAMS=$DOMAIN{HOST},$DOMAIN{IP},$DOMAIN{CONFIG} and now you want to extract what's within the braces? Like this:
use strict; use warnings; my $str='$DOMAIN{HOST},$DOMAIN{IP},$DOMAIN{CONFIG}'; my @result = $str =~ /{(.+?)}/g; print "@result\n";
Update: Putting it all together:
use strict; use warnings; use Data::Dumper; my %h = map {my($k, $v)=/^(.*?)=(.*)/; $v=[ $v=~/{(.+?)}/g ] if $v=~/} +/; $k=>$v } <DATA>; print Dumper \%h; __DATA__ DEPLOY_TIME=300 DEPLOY_TYPE=OS DEPLOY_PARAMS=$DOMAIN{HOST},$DOMAIN{IP},$DOMAIN{CONFIG} DEPLOY_DEFAULT_STARTUP=$DOMAIN{STARTUP.INI} DEPLOY_DEBUG=Y DEFAULT_EXPIRY=900
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex random values pattern match and code efficiency
by Mark.Allan (Sexton) on Sep 12, 2013 at 18:04 UTC | |
by hdb (Monsignor) on Sep 12, 2013 at 18:07 UTC |