in reply to repetition of qw: syntax error

I'm guessing that the reason this sort of construct is not directly supported in "non-blead" perl is that, as a syntactic form, it has an inherent sort of ambiguity about it: should  qw/foo bar/ x 5 produce qw/foo foo ... bar bar .../, or qw/foo bar foo bar .../ (or "foo foo ... bar bar ..." or "foofoo...barbar...", etc)?

It would be the kind of syntax where nearly everyone who chose to use it would end up having to read the man page every time, to make sure it really does what they want, and those who see it in someone else's code need to look it up to see what it really does.

Personally, I would be content to use a more mundane -- but non-ambiguous -- approach like:

my @base = qw/foo bar/; my @redup; push @redup, @base for ( 1..5 ); # qw/foo bar foo bar .../ # or for ( @base ) { push @redup, $_ for (1..5) } # qw/foo foo ... bar bar +.../ # or my $redup = join " ", map { "@base" } (1..5) # "foo bar foo bar ..." # etc.

Replies are listed 'Best First'.
Re^2: repetition of qw: syntax error
by ysth (Canon) on Jun 23, 2005 at 08:16 UTC
    I'm guessing that the reason this sort of construct is not directly supported in "non-blead" perl is that, as a syntactic form, it has an inherent sort of ambiguity about it
    No, it was a blatant bug that made it not work (along with other things such as qw/1 2/ * 3). I'm pretty sure the recent fix will be included in 5.8.8 in due time.