in reply to Re^2: Perl oddities
in thread Perl oddities
I am aware of the method suggested by gaal. I usually do not use it because I almost always wrap the regex up with an 'if'. Throw in a my function and it starts to get messy.
This business doesn't DWYM:# Ugly to me... if (my ($this, $that, $some, $other) = $line =~ /(this).*(that).*(some +).*(other)/) { do_it(); }; # Better, I think... if ($line =~ /(this).*(that).*(some).*(other)/) { my ($this, $that, $some, $other) = ($1, $2, $3, $4); do_it(); }
The magical string incrementer is summoned to build a list of strings starting with the first capture, ending with the last.my ( $this, $that, $some, $other, $foo, $bar, $baz ) = ( $1 .. $+ );
YuckFoo
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Perl oddities
by ihb (Deacon) on Mar 01, 2005 at 22:10 UTC |
In Section
Meditations