in reply to Regex random values pattern match and code efficiency
As for the first question, I'd do something like this:
use strict; use warnings; my %h; while (<DATA>) { chomp; my ($key, $value) = split /=/, $_, 2; $h{$key} = $value; } print $h{DEPLOY_PARAMS}, "\n"; __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
(That is, parse the whole file with the same code, instead of parsing each value with a different regex).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Regex random values pattern match and code efficiency
by Mark.Allan (Sexton) on Sep 12, 2013 at 05:50 UTC | |
by Anonymous Monk on Sep 12, 2013 at 14:13 UTC | |
by AlexTape (Monk) on Sep 12, 2013 at 14:14 UTC | |
by Mark.Allan (Sexton) on Sep 13, 2013 at 12:18 UTC |
In Section
Seekers of Perl Wisdom