P
Peter Kay
I want to pass in arguments to a subroutine via an array or list.
Seems simple enough, right? Well, no, because the array keeps getting
kicked into scalar context. An example perl script is provided:
Any thoughts?
Thanks,
--Peter
------------------------------
#!/usr/bin/perl -w
use strict;
sub do_it ($$@);
my @args=("a","b","c");
do_it( "a", "b", @args ); #works
do_it( @args ); # Doesn't work:
# Not enough arguments for main::do_it at g.pl line 9, near "@args )"
# Execution of test.pl aborted due to compilation errors.
sub do_it ($$@)
{
my ($a, $b, @c) = @_;
print("Loaded $a, $b, others of @c\n");
}
Seems simple enough, right? Well, no, because the array keeps getting
kicked into scalar context. An example perl script is provided:
Any thoughts?
Thanks,
--Peter
------------------------------
#!/usr/bin/perl -w
use strict;
sub do_it ($$@);
my @args=("a","b","c");
do_it( "a", "b", @args ); #works
do_it( @args ); # Doesn't work:
# Not enough arguments for main::do_it at g.pl line 9, near "@args )"
# Execution of test.pl aborted due to compilation errors.
sub do_it ($$@)
{
my ($a, $b, @c) = @_;
print("Loaded $a, $b, others of @c\n");
}