tlhf has asked for the wisdom of the Perl Monks concerning the following question:
The parser sees the option explicit, and realises that that means use strict. It sees the dim x(), and realises that that means my(@x). It understands that x is an array, and the parser always treats a solitry x as @x. And it goes forth, so the translation comes out roughly as;option explicit dim x() x = split("john,biran,someone",",") response.write(x(0) & x(2))
The @x[0] isn't clean, but it will do for now. This code works fine, and all is well. Well; all is well when we have wonderous option explicit. Unfortunately, there are many naughty VBScript developers who don't use option explicit. They don't define their variables. And my module gets very confused.use strict; my (@x); @x = b_split('john,biran,someone',','); $response->write(@x[0] . @x[2]); sub b_split { # not fully finished, needs $count and $compare my ($string, $delimiter, $count, $compare) = @_; $delimiter = quotemeta($delimiter); return split(/$delimiter/, $string); }
Which is all kinds of wrong. So, I started my quest for the solution.$x = b_split('john,biran,someone',','); print($x[0]; . $x[2]); sub b_split { # not fully finished, needs $count and $compare my ($string, $delimiter, $count, $compare) = @_; $delimiter = quotemeta($delimiter); return split(/$delimiter/, $string); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A Tricky Problem with Context
by stephen (Priest) on Apr 07, 2002 at 21:32 UTC | |
|
Re: A Tricky Problem with Context
by ilcylic (Scribe) on Apr 08, 2002 at 02:42 UTC | |
|
Re: A Tricky Problem with Context
by RSevrinsky (Scribe) on Apr 08, 2002 at 08:37 UTC | |
by Juerd (Abbot) on Apr 08, 2002 at 09:40 UTC | |
by tlhf (Scribe) on Apr 08, 2002 at 14:34 UTC |