S5: array interpolation

2004-09-15 Thread John Siracusa
 An interpolated array:
 
 / @cmds /
 
 is matched as if it were an alternation of its elements:
 
 / [ @cmds[0] | @cmds[1] | @cmds[2] | ... ] /
 
 As with a scalar variable, each one is matched as a literal.

Like this?  (Assuming single quotes don't interpolate @foo[...])

@a = ('a', 'b', 'c');

'@a[0]' ~~ m:/ @a /; # true
'@a[2]' ~~ m:/ @a /; # true
'@a[9]' ~~ m:/ @a /; # false

If so, that seems pretty wacky...

-John




Re: S5: array interpolation

2004-09-15 Thread Brent 'Dax' Royal-Gordon
John Siracusa [EMAIL PROTECTED] wrote:
  An interpolated array:
 
  / @cmds /
 
  is matched as if it were an alternation of its elements:
 
  / [ @cmds[0] | @cmds[1] | @cmds[2] | ... ] /
 
  As with a scalar variable, each one is matched as a literal.
 
 Like this?  (Assuming single quotes don't interpolate @foo[...])
 
 @a = ('a', 'b', 'c');
 
 '@a[0]' ~~ m:/ @a /; # true
 '@a[2]' ~~ m:/ @a /; # true
 '@a[9]' ~~ m:/ @a /; # false

I think he means as opposed to a subrule.  In Perl 5 terms, there's
an implicit \Q\E around each value in the array.

-- 
Brent 'Dax' Royal-Gordon [EMAIL PROTECTED]
Perl and Parrot hacker

There is no cabal.
[I currently have a couple Gmail invites--contact me if you're interested.]