Jonathan Lang wrote:
Another thing to note about given ... when: you don't have to use them
together. All that "given" does is to set $_ to the variable
provided; this can be used in a manner similar to "with" statements in
other languages. And "when" doesn't have to be inside a "given"
block, either: it can be used in any block that sets $_. For example:
for @list {
when *..^0 { say "$_ is negative" }
when 0 {say "$_ is zero" }
when 0^..* { say "$_ is positive" }
default { say "$_ is something else" }
}
or (I think):
method test ($value) {
setup();
when $value { doit() } #[smart-match the calling object $_ against $value.]
}
(Question: assuming that the above is valid, would breaking out of the
when block be the same as returning from the method? Or would it
qualify as an abnormal termination of the method?)
I was exactly thinking at the 'with' keyword for given.
Even if it is not exactly the same thing.
the construct for ... when sounds more natural to me
even if here it is with an array, could be :
for $operator {
'' {}
'' {}
default {}
}
but as Mr. Wall said,
2 different things, 2 idioms.
--
シリル・デュモン(Cyrille Dumont)
[EMAIL PROTECTED]
our work is the portrait of ourselves
tel: 03-5690-0230 fax: 03-5690-7366
http://www.comquest.co.j