mordibity has asked for the wisdom of the Perl Monks concerning the following question:
I've found it very convenient to parse it like this:my $raw = "foo=1 $baR= red BOO = 5.6 Baz =3";
Which gives me: (foo => 1, baR => "BOO", Baz => 3) However, ideally, I would like all the keys of my hash to be lowercase so I can than ignore case later when I do lookups. 'map { lc } ' won't work because I'm biting off tokens two at a time. Is there a Perlish way to do this all in one go? (ie, without capturing the matches in a separate step and lowercase the left-hand-side). Thanks!my %params = $raw =~ /(\S+)\s*=\s*(\S+)/g;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: lowercasing during a match?
by jmcnamara (Monsignor) on Aug 23, 2002 at 14:58 UTC | |
|
Re: lowercasing during a match?
by fruiture (Curate) on Aug 23, 2002 at 14:38 UTC | |
|
Re: lowercasing during a match?
by particle (Vicar) on Aug 23, 2002 at 15:46 UTC | |
|
Re: lowercasing during a match?
by dws (Chancellor) on Aug 23, 2002 at 16:51 UTC | |
|
Re: lowercasing during a match?
by BrowserUk (Patriarch) on Aug 23, 2002 at 14:46 UTC | |
|
Re: lowercasing during a match?
by fglock (Vicar) on Aug 23, 2002 at 14:36 UTC |