in reply to most appropriate return data type
Gives:use warnings; use strict; sub mysub1 { my @fred = qw(The quick brown fox); return @fred; } sub mysub2 { return qw(The quick brown fox); } my $x = mysub1(); print "x: $x\n"; my $y = mysub2(); print "y: $y\n";
You could always use wantarray to return a list or a scalar, depending on the context.x: 4 y: fox
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: most appropriate return data type
by Anonymous Monk on Feb 19, 2010 at 15:52 UTC | |
by shmem (Chancellor) on Feb 19, 2010 at 16:09 UTC | |
by merlyn (Sage) on Feb 19, 2010 at 16:43 UTC | |
by TGI (Parson) on Feb 24, 2010 at 20:38 UTC | |
by cdarke (Prior) on Feb 19, 2010 at 16:44 UTC |