Dave Whipp wrote:

> Today I wrote some perl5 code for the umpteenth time. Basically:
>   for( my $i=0; $i< $#ARGV; $i++ )
>   {
>      next unless $ARGV[$i] eq "-f";
>      $i++;
>      $ARGV[$i] = absolute_filename $ARGV[$i];
>   }
>   chdir "foo";
>   exec "bar", @ARGV;
> I'm trying to work out if there's a clever perl6 way to write this
> using pattern matching:
>   for @*ARGV -> "-f", $filename {
>     $filename .= absolute_filename;
>   }
> Would this actually work, or would it stop at the first elem that
> doesn't match ("-f", ::Item)?
> Is there some way to associate alternate codeblocks for different
> patterns (i.e. local anonymous MMD)?
That's given/when. I seem to recall that C<given> and C<for> do not
topicalize the same way, by design, but my recollection may be dated.

If I'm wrong, then:

for ... { when "-f" { ... }}

If I'm right, then there is probably an argument for a standalone "when"
that uses the default topic, or for some sort of shorthand to coerce a
unified topicalization.


Reply via email to