in reply to Re^4: Question on Regex grouping
in thread Question on Regex grouping
People who dislike list slicing should avoid scripting languages, especially Perl.Really? Just because I find list slices to avoid using $1 ugly? What else? People who don't like goto should avoid Perl? People who don't like m?? should avoid Perl? People who don't like code without warnings or strict?
@X = ($x =~ /#/g)[1,3];Ain't working. Sure, for the given pattern, it works. Now, let's change the pattern a little, shall we:
So, @X is empty, yet the pattern matches.my $x = "1234"; my @X = ($x =~ /(#)?/)[1,3]; say scalar @X; # defined(@X) is deprecated say "Matched" if $x =~ /(#)?/; __END__ 0 Matched
It prints NO ... therefore, JavaFan, your assertions are FALSE and FALSE.When I say "it doesn't always work", a single example where it does work isn't a contradiction.
Note also that Marshall wasn't doing it your way anyway, he put the list slice in scalar context.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Question on Regex grouping
by TenThouPerlStudents (Initiate) on Dec 22, 2010 at 18:39 UTC |