[WHY not HOW] Re: [Israel.pm] Quickie - Perl syntax

Gaal Yahas gaal at forum2.org
Wed Oct 6 06:15:03 PDT 2004

On Wed, Oct 06, 2004 at 02:07:04PM +0200, Madani, Srikanth, VF-DE wrote:
> Here's the solution:
> my @tdir_val = ($line =~ m/^\s*(\S+)\s*=\s*(\S+)\s*$/);

Except that it doesn't work if there are whitespaces you need cleaning
within the key or the value, like so:

     key 1 = value 2

Assuming you want qw(key1 value2) in this case -- and that's what I'd
guessed from your original wording, one way to do it would be:

     my @result = map { s/\s*//g; $_ } split /=/, $line

Though looking again now at your data and the variable name in your
solution I suppose that wasn't what you were after. Oh well :)

Gaal Yahas <gaal at forum2.org>

More information about the Perl mailing list