Is there an ARRAY designator for REGEX vals?

S

Spydo

I vaguely recall this was asked before so I apologize if its a repeat
but I can't find an answer. Which implies the answer is no. But I'm
hoping I'm wrong..

We have the convenience of @_ defined as( $_[0], $_[1], ... ,$_[-1] )

is there a similar array for @something defined as ( $1, $2, $3, ... ,
$n )

?

if not, it would be useful, since on-occasion I find I need ( $1, $2,
$3, ... ,$n ) which would be more concisely written @something..



Respectfully,
Mr S
 
E

Ed Mills

In list context, the match operator returns a list of matched subexp-
ressions, as in:

  my @matches = $string =~ m/(foo)(bar)(baz)/;

  my ($foo, $bar, $baz) = m/(foo)(bar)(baz)/;

Also possibly of interest, after a successful match, @- and @+ contain
the start and end offsets of the match and any submatches.

sherm--

oh oh oh- this is an epiphany for me thank-you. I always wondered what
that n did you were a huge help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,213
Messages
2,571,108
Members
47,699
Latest member
lovelybaghel

Latest Threads

Top