in reply to Re: Perl variable scoping between functions
in thread Perl variable scoping between functions
Thanks. Your sub as written does not return anything so the @retarr array will be empty. You need to return a list like this:
#!/usr/bin/env perl use strict; use warnings; use Data::Dumper; my @retarr = (); print "At init " . Dumper (\@retarr); @retarr = void (); print "After void " . Dumper (\@retarr); @retarr = getlist (); print "After getlist " . Dumper (\@retarr); exit; sub void { # doesn't return anything } sub getlist { return (0, 1, 2); }
That is an SSCCE. See also return. HTH.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl variable scoping between functions
by Bryan882 (Novice) on Jul 18, 2018 at 10:55 UTC | |
by hippo (Archbishop) on Jul 18, 2018 at 11:22 UTC |