Hi all,
I want to write a subroutine that takes an array and a hash as input
parameters and then does some work on them. I can't seem to determine
how to do this however; it seems that with a subroutine, all you can
pass is a single array ( which appears as @_ ) to the subroutine.
The program I am trying to write is below:
#!/usr/bin/perl
sub mysub
{
@my_array = @_;
%my_hash = %_;
print "Print the array\n";
foreach (@my_array)
{
print "$_ \n";
}
print "Now print the hash\n";
print $my_hash{"first"};
print $my_hash{"second"};
print $my_hash{"third"};
}
my %the_hash;
my @the_array;
$the_array[0] = 5;
$the_array[1] = 43;
$the_array[2] = 78;
$the_hash{"first"} = "number1\n";
$the_hash{"second"} = "foo\n";
$the_hash{"third"} = "abc\n";
mysub (@the_array,%the_hash);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
- converting "strange" characters Duarte Cordeiro
- Re: converting "strange" characte... Josimar Nunes de Oliveira
- Re: passing an array and a hash to a su... David Buddrige
- Re: passing an array and a hash to ... David Buddrige
- Re: passing an array and a hash... Sudarshan Raghavan
- Re: passing an array and a hash to ... David Buddrige
- Re: passing an array and a hash to ... John W. Krahn