Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The script returns:#!/usr/bin/perl wr_module("1"); wr_module("2"); wr_module("3"); exit; sub wr_module { my $x=shift; my $wire0; my @wire1; my @wire2; print("Adding $x "); $wire0.=$x; $wire1[1].=$x; $wire2{"a"}.=$x; print(" => $wire0 :: $wire1[1] :: $wire2{\"a\"} \n"); }
I would expect:Adding 1 => 1 :: 1 :: 1 Adding 2 => 2 :: 2 :: 12 Adding 3 => 3 :: 3 :: 123
Do you have an idea, why the "my" is not working for @wire2 ? Thanks for your help !Adding 1 => 1 :: 1 :: 1 Adding 2 => 2 :: 2 :: 2 Adding 3 => 3 :: 3 :: 3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using local variables
by Corion (Patriarch) on Mar 16, 2016 at 10:24 UTC | |
by Anonymous Monk on Mar 16, 2016 at 10:37 UTC | |
|
Re: using local variables
by Eily (Monsignor) on Mar 16, 2016 at 10:30 UTC |