in reply to Re^7: Pointers and References
in thread Pointers and References

yep

use strict; use warnings; my $x = 12; foreach my $aa ($x,$x){ $aa = 13; } print $x; ---------- 13

How about "readonly, anonymous stack" instead of list? Iam joking, enough of the nomenclature

Replies are listed 'Best First'.
Re^9: Pointers and References
by AnomalousMonk (Archbishop) on Nov 24, 2020 at 22:18 UTC

    And also for arrays:

    Win8 Strawberry 5.8.9.5 (32) Tue 11/24/2020 17:09:57 C:\@Work\Perl\monks >perl -Mstrict -Mwarnings -l my $x = 1; my $y = 2; my @z = (3, 4, 5); $_ += 100 for @z, $x, $y; print "$x, $y, (@z)"; for ($x, @z, $y) { $_ += 100; } print "$x, $y, (@z)"; ^Z 101, 102, (103 104 105) 201, 202, (203 204 205)


    Give a man a fish:  <%-{-{-{-<

Re^9: Pointers and References
by LanX (Saint) on Nov 25, 2020 at 13:55 UTC
    I hope the distinction between list and arrays is clearer now, I know its confusing.

    E.g. this is a list assignment without literal list: @a = %a ,

    ... the hash is unpacked into a list which is packed into an array.

    or here you need a literal list to init an array(-ref) : $a_ref = [ 1,2,3 ]

    Please feel free to ask. :)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      Sure, thanks! I will ask if I have a problem.