in reply to passing variables to a subroutine
my $proph=@_;
Using an array (here @_) in scalar context returns the number of elements in the array , and is not what you want.
Typical solutions are (use only one of them)
my $proph = shift; # defaults to @_ my ($proph) = @_; # list context instead my $proph = $_[0]; # be explicit about wanting the first element
See perlintro and perlsub for more details.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: passing variables to a subroutine
by AWallBuilder (Beadle) on Jul 04, 2012 at 09:11 UTC | |
by AnomalousMonk (Archbishop) on Jul 04, 2012 at 16:23 UTC |
In Section
Seekers of Perl Wisdom