Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Is there an ARRAY designator for REGEX vals?
January 25, 2011, 7:17 pm
rate this thread
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( $_, $_, ... ,$_[-1] )
is there a similar array for @something defined as ( $1, $2, $3, ... ,
if not, it would be useful, since on-occasion I find I need ( $1, $2,
$3, ... ,$n ) which would be more concisely written @something..
Re: Is there an ARRAY designator for REGEX vals?
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.
- » FAQ 6.9 How can I quote a variable to use in a regex?
- — Next thread in » PERL Discussions