a whole heap of key=value pairs, easy enough. but I want to see if I can optimise what I already have done
I guess that depends on how you define "optimise". That could mean reusing existing code (thereby optimizing development time) unless there is a reason not to (such as computational speed, which is another thing that can be optimized).
Since your input is a bunch of "key=value" pairs, you could use one of the many config modules that parse ini-like files.
Prints:use warnings; use strict; use Config::General; my $string = 'to=<adam.clark@ngv.vic.gov.au>, relay=monet1.ngv.vic.gov +.au[10.10.10.20]:25, delay=0.54, delays=0.06/0.02/0/0.46, dsn=2.0.0, +status=sent '; $string =~ s/, /\n/g; my $conf = Config::General->new( -String => $string ); my %hash = $conf->getall(); while( my ( $k, $v ) = each %hash ) { print "$k => $v\n"; }
to => <adam.clark@ngv.vic.gov.au> relay => monet1.ngv.vic.gov.au[10.10.10.20]:25 dsn => 2.0.0 status => sent delay => 0.54 delays => 0.06/0.02/0/0.46
In reply to Re: Adapting parenthesis in regexps
by bobf
in thread Adapting parenthesis in regexps
by cyzza
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |