New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
re modifier "h" - return named captures as hash expression #12893
Comments
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
|
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. |
The RT System itself - Status changed from 'new' to 'open' |
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 |
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 |
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 |
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 -- |
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 |
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; |
From @daxim
Same as %+.
Expression returns (foo => 'b') |
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 |
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 |
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 -- |
From @davidnicol
the AAAD can be minimized with my %date = do { $d =~ m{$fmt1|$fmt2|$fmt3} ? %+ : () }; can it not? |
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 |
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} ? %+ : (); |
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$
The text was updated successfully, but these errors were encountered: