in reply to perl -e hash assignment and range operator bug
>> So I test it out, like i do everything, and i do: perl -e"%a=( 1..10, 11..20 );print keys %a" and I get no output.
Well, when I test in on my one and only Perl (5.6.1 build 628 on Win2k), I get this
or in a more readable versionH:\>perl -e"%a=( 1..10, 11..20 );print keys %a" 137159117319115
both of which look good to me.H:\>perl -e"%a=( 1..10, 11..20 );print qq{@{[keys %a]}}" 13 7 15 9 1 17 3 19 11 5
crazyinsomniac continued
>> So now I says to me, this must be a bug, and to confirm, i try:
which yields nada, and then ...perl -MData::Dumper -e "%a= 1 .. 10, 2 .. 11 ;print Dumper \%a"
Me again, when I test it, I get this - as expected.
Seems to work nicely. The % character that japhy mentioned is tucked inside the double quotes and is seen by Perl, not the cmd shell.H:\>perl -MData::Dumper -e "%a= 1 .. 10, 2 .. 11 ;print Dumper \%a" $VAR1 = { '7' => 8, '9' => 10, '1' => 2, '3' => 4, '5' => 6 };
So where is the problem? Did I miss something here?
I am all for bashing the cmd shell (pun intended) when justified, but here I cannot confirm the problem.
Can you help me out on this, crazyinsomniac ?
Update Could somemonk please set me straight on the operator precedence in the second example above?
I think that the assignment binds 1..10 to %a, whereas 2..11 has no effect other than being the return value from the comma operator, which is thrown away. Is this correct?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(crazyinsomniac) Re^2: perl -e hash assignment and range operator bug
by crazyinsomniac (Prior) on Aug 27, 2001 at 05:08 UTC | |
by Rudif (Hermit) on Aug 28, 2001 at 02:09 UTC |