in reply to Perl assign scalar to array
Hello bagyi,
You’re right, it’s not working, but you don’t need to use strict to see that:
23:34 >perl -MData::Dump -wE "my @a = ('a'..'j'); @a[2..5] = 2; dd \@a +;" ["a", "b", 2, undef, undef, undef, "g" .. "j"] 23:35 >
(Assigning 2 here is equivalent to assigning a list with 2 as the only element. The missing elements default to undef.)
Slices are documented in perldata#Slices.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl assign scalar to array
by ikegami (Patriarch) on Oct 14, 2015 at 19:32 UTC | |
by Athanasius (Archbishop) on Oct 15, 2015 at 06:43 UTC |