Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upre modifier "h" - return named captures as hash expression #12893
Comments
This comment has been minimized.
This comment has been minimized.
From @daximCreated by @daximExample code adapted from perlretut. Make the C<h> (mnemonic I<hash>) flag work (that line with the C<m> my $fmt1 = '(?<y>\d\d\d\d)-(?<m>\d\d)-(?<d>\d\d)'; for my $d (qw(2006-10-21 15.01.2007 10/31/2005)) { Works the same as: if ($d =~ m{$fmt1|$fmt2|$fmt3}) { Rationale: side effects are a weird-ass way to program in a language length($something); Perl Info
|
This comment has been minimized.
This comment has been minimized.
From @jkeenanOn Tue Apr 02 07:36:23 2013, daxim wrote:
This RT is a request for a new feature: a new regex modifier '/h'. Is there any support for development of this new feature? (I ask, in Is there anyone who wants to try to write an implementation for this new Thank you very much. |
This comment has been minimized.
This comment has been minimized.
The RT System itself - Status changed from 'new' to 'open' |
This comment has been minimized.
This comment has been minimized.
From tchrist@perl.com"James E Keenan via RT" <perlbug-followup@perl.org> wrote
I am opposed. If it "works the same as", we don't need another way. It increases the cognitive load unnecessarily for no real gain. And I don�t want us to keep adding /mods. We have to think of --tom |
This comment has been minimized.
This comment has been minimized.
From gottreu@gmail.com
I kinda like the idea. On 06/29/2013 02:36 PM, Tom Christiansen wrote:
Could you clarify what you mean by embed and what the antecedent of Since =~ binds a scalar expression to a pattern match, essentially ($d, %date) =~ m{...} # %date = %+ and it would still return the same value (depending on context of course). Following down that path, one could imagine ($d, $lvalue) =~ s{...}{...} # set /r implicitly ($d, @matches) =~ m{...} # @matches = ($1,$2,$3,...) Or a functional interface could be used: match(qr/.../, $d, named_captures => \%date) I'm not necessarily advocating for any of these, it's just what I Brian Gottreu |
This comment has been minimized.
This comment has been minimized.
From tchrist@perl.comBrian Gottreu <gottreu@gmail.com> wrote on Sat, 29 Jun 2013 18:03:43 CDT:
The antecedent of �them� is /mods, like /acdgilmopsux, stressed on the I don�t like the idea of single-character signifiers carrying so much --tom |
This comment has been minimized.
This comment has been minimized.
From @iabynOn Sat, Jun 29, 2013 at 01:36:52PM -0600, Tom Christiansen wrote:
If there were such a modifier (and I agree that it should be "better" than -- |
This comment has been minimized.
This comment has been minimized.
From @daximtchrist:
Then please go ahead and remove the code responsible for return value L<Perl 1 capture variables|http://perldoc.perl.org/
The real gains are: * The match operator restores feature parity. When named captures were match op/capturing|unnamed|named * In the future, C<no re 'side-effects'> becomes possible which On the other side of the scale is: * One more flag where there are already twelve. But this is hardly a straw that will break the camel's back. It's up to Brian:
I don't like that because it requires a variable. This is hardly an A simple list of return values can flow freely between chained/nested davem:
Don't let that get in the way of the feature request under discussion. PS: I'm answering via RT web interface, no idea where in the p5p thread |
This comment has been minimized.
This comment has been minimized.
From @HugmeirOn Tue, Apr 2, 2013 at 11:36 AM, Lars Dɪ����ᴡ 迪�� <perlbug-followup@perl.org
How would it work with code that mixes traditional & named captures? For my %matches = "ab" =~ /(.)(?<foo>.)/h; |
This comment has been minimized.
This comment has been minimized.
From @daxim
Same as %+.
Expression returns (foo => 'b') |
This comment has been minimized.
This comment has been minimized.
From @cpansproutWARNING: Bikes shedding their paint ahead. On Mon Jul 01 03:38:27 2013, davem wrote:
use v5.20; Or: /(?+ignorecase multiline hash)...../ with these variations as well: (?+named flags:pattern) -- Father Chrysostomos |
This comment has been minimized.
This comment has been minimized.
From @khwilliamsonOn 07/01/2013 06:51 PM, Father Chrysostomos via RT wrote:
An idea I had quite some time ago was like this: m/(?^u{multiline, -ignorecase, ...}:foo)/ in which long modifier names would come enclosed in braces anywhere |
This comment has been minimized.
This comment has been minimized.
From @demerphqOn 2 July 2013 02:51, Father Chrysostomos via RT
FWIW, I hate it, and I would be against new modifiers you can only put My view is Perl has regex modifiers and its too late to argue about it anymore. Yves -- |
This comment has been minimized.
This comment has been minimized.
From @davidnicol
the AAAD can be minimized with my %date = do { $d =~ m{$fmt1|$fmt2|$fmt3} ? %+ : () }; can it not? |
This comment has been minimized.
This comment has been minimized.
From gottreu@gmail.comOn 07/02/2013 01:00 AM, David Nicol wrote:
Actually no it seems. $ perl -MData::Dumper -we \ It looks like it's been that way since at least 5.10.1. Is this a bug? Brian Gottreu |
This comment has been minimized.
This comment has been minimized.
From @ikegamiOn Tue, Jul 2, 2013 at 2:00 AM, David Nicol <davidnicol@gmail.com> wrote:
or my %date = ( $d =~ m{$fmt1|$fmt2|$fmt3} ? %+ : () ); or my %date = $d =~ m{$fmt1|$fmt2|$fmt3} ? %+ : (); |
This comment has been minimized.
This comment has been minimized.
From @cpansproutOn Mon Jul 01 22:49:20 2013, demerphq wrote:
I actually agree with you on that last point. I had just resigned -- Father Chrysostomos |
Migrated from rt.perl.org#117447 (status was 'open')
Searchable as RT117447$