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
qw and x operators doesn't mix #7919
Comments
From @salvaCreated by @salvafor instance $ perl -e 'print qw|foo bar| x 3' while $ perl -e '$,="-"; print ((qw|foo bar|) x 3)' produces the desired behaviour Cheers - Salvador. Perl Info
|
From @salvaCreated by @salvafor instance: $ perl -e '@foo = qw(foo bar) x 3' I would expect 'qw(foo bar) x 3' to behave as '(qw(foo bar)) x 3' Cheers, - Salvador. Perl Info
|
From @ysthOn Thu, May 19, 2005 at 04:12:45PM -0000, Salvador Fandi���±o wrote:
perlop says: In list context, if the left operand is enclosed in I would rather not add qw to that as an additional special case; To get qw/foo bar foo bar foo bar/, just enclose the qw// in parentheses: |
The RT System itself - Status changed from 'new' to 'open' |
From @salva--- Yitzchak Scott-Thoennes via RT <perlbug-followup@perl.org> wrote:
that doesn't work either, did you meant... (qw/foo bar/) x 3 ? cheers, - Salvador |
From @ysthOn Thu, May 19, 2005 at 11:13:44PM -0700, Salvador Fandiño wrote:
Oops. Yes. |
From @rgsYitzchak Scott-Thoennes wrote:
There's indeed a bug, since the tokenizer doesn't set its state --- toke.c (revision 4822) But... technically I agree with Yitzchak on the exegesis of perlop, $ ./pugs -e 'say for qw(foo bar) xx 2' (asking on #perl6 confirms this.) $ bleadperl -le 'print for qw(foo bar) x 2' |
From @ysthOn Fri, May 20, 2005 at 11:07:25AM +0200, Rafael Garcia-Suarez wrote:
That's the opposite of what I was trying to say. I think of ()x and x |
From @rgsYitzchak Scott-Thoennes wrote:
Yes, I'm quite aware of this :) A "nonetheless" is missing in my
Yes... but from a DWIM point of view I think that people are used to Perl 6 works around this difficulty by having separate x and xx |
From @ysthOn Fri, May 20, 2005 at 11:07:25AM +0200, Rafael Garcia-Suarez wrote:
Is p6's xx supposed to have both roles of p5's x? It sure seems to work differently; I'm told that this: ./pugs -e 'sub foo { ("foo","bar") } say for foo() xx 2' produces also, while for perl5, we have: $ ./perl -le'sub foo { ("foo","bar") } print for foo() x 2' |
From @demerphqOn 5/20/05, Rafael Garcia-Suarez <rgarciasuarez@mandriva.com> wrote:
theres precedence for this interpretation as well: D:\dev>perl -wle "use strict; for my $x qw(foo bar baz) { print $x }" -- |
From @rgsYitzchak Scott-Thoennes wrote:
No; as Synopsis 03 says : x splits into two operators: x (which concatenates repetitions of a
I don't see the point... My point was that qw() forces immediate list |
From @rgsRafael Garcia-Suarez wrote:
I applied this as change 24560 to bleadperl, with a regression test that is( (join ',', (qw(a b c) x 3)), 'a,b,c,a,b,c,a,b,c', 'x on qw produces list' ); -- |
@rgs - Status changed from 'open' to 'resolved' |
From @ysthOn Tue, May 24, 2005 at 01:51:52PM +0200, Rafael Garcia-Suarez wrote:
Inline Patch--- perl/pod/perlop.pod.orig 2005-05-10 08:07:42.000000000 -0700
+++ perl/pod/perlop.pod 2005-05-24 08:50:05.524456000 -0700
@@ -250,9 +250,9 @@
operand is not enclosed in parentheses, it returns a string consisting
of the left operand repeated the number of times specified by the right
operand. In list context, if the left operand is enclosed in
-parentheses, it repeats the list. If the right operand is zero or
-negative, it returns an empty string or an empty list, depending on the
-context.
+parentheses or is a list formed by C<qw/STRING/>, it repeats the list.
+If the right operand is zero or negative, it returns an empty string
+or an empty list, depending on the context.
print '-' x 80; # print row of dashes
End of Patch. |
From @rgsYitzchak Scott-Thoennes wrote:
Right; thanks, applied as change #24567. |
Migrated from rt.perl.org#35885 (status was 'resolved')
Searchable as RT35885$
The text was updated successfully, but these errors were encountered: