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
Assignment to List Breaks \G. #903
Comments
From ralph@inputplus.demon.co.ukAssigning a /gx regexp to a list breaks \G in the following regexp. #! /usr/local/bin/perl -w $_ = 'a 1 b 2 c 3'; print "bug\n"; print "workaround\n"; Output is bug Here's the configuration of my perl at home, but the one at work, Ralph. Site configuration information for perl 5.00404: Configured by root at Thu Sep 10 02:15:30 EDT 1998. Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration: |
From @tamiasOn Tue, Nov 30, 1999 at 04:10:20PM +0000, Ralph Corderoy wrote:
This is the expected behavior for m//g in a list context. The regular Try this instead: #! /usr/local/bin/perl -w $_ = 'a 1 b 2 c 3'; @a = /\G(\w)\s(\d)\s?/gx; Output: a,1,b,2,c,3 Ronald |
From [Unknown Contact. See original ticket]
Sound correct behaviour to me. From perlop: /PATTERN/cgimosx c Do not reset search position on a failed match when /g is in effect. It just appears that your list is too small to hold the rest of the matches. And as Hope it helps, François Désarménien |
From [Unknown Contact. See original ticket]Ronald J Kimball writes:
I remember some discussion for making list context m//gc behave differently. What was the result? Ilya |
From @RandalSchwartz
Ilya> I remember some discussion for making list context m//gc behave differently. Ilya> What was the result? If I recall (since it was me that brought it up), nothing. :( Here's the thread, where I use the term "thread" loosely http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1999-10/msg01047.html I know, *patches welcome*. :) -- |
From [Unknown Contact. See original ticket]Ronald J Kimball writes:
Hi, thanks for all the replies. Having put -Dr to good use I fully http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1999-10/msg01047.html there might be others that agree. Normally, the use of context in Perl to `do the right thing' works well. If I want to match many times, possibly leaving pos alone on failure, @w = /(\w+)/g; But if I want to do some lexing then I need /g to enable \G. As long as if (/(\w)+/gc) { but if I want to assign to a list I'm stuck; that would create a list if (($foo) = /(\w)+/gc) { # bad I want to give a list context for assignment to variables and I need \G If there was a /l for lexing that enabled \G without adding the global if (($foo) = /(\w)+/lc) { # bad Making /gc work so pos wasn't reset on the last, guaranteed to fail, ($foo) = /(\w+)\s*/lc; # takes one word. To sum up, /g means two things (many matches and enable \G), it means Thanks for your time. Ralph. |
From [Unknown Contact. See original ticket]Hi, I'm sending this again as I suspect that sending it from a ------- Forwarded Message Date: Wed, 01 Dec 1999 17:04:01 +0000 Ronald J Kimball writes:
Hi, thanks for all the replies. Having put -Dr to good use I fully http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1999-10/msg01047.html there might be others that agree. Normally, the use of context in Perl to `do the right thing' works well. If I want to match many times, possibly leaving pos alone on failure, @w = /(\w+)/g; But if I want to do some lexing then I need /g to enable \G. As long as if (/(\w)+/gc) { but if I want to assign to a list I'm stuck; that would create a list if (($foo) = /(\w)+/gc) { # bad I want to give a list context for assignment to variables and I need \G If there was a /l for lexing that enabled \G without adding the global if (($foo) = /(\w)+/lc) { # bad Making /gc work so pos wasn't reset on the last, guaranteed to fail, ($foo) = /(\w+)\s*/lc; # takes one word. To sum up, /g means two things (many matches and enable \G), it means Thanks for your time. Ralph. ------- End of Forwarded Message |
Migrated from rt.perl.org#1838 (status was 'resolved')
Searchable as RT1838$
The text was updated successfully, but these errors were encountered: