Greetings. I have a newbie question about passing arrays into a subroutine
(and getting return values as well).

My script uses arrays for various values -- one array each for TCP port
numbers, UDP port numbers, and the different bytes of IP addresses.

Since I have to populate each of these arrays, I was hoping to be able to
use one subroutine for all of them, just by feeding the subroutine the name
of the array, the starting value, and the number of elements in the array.

Unfortunately, the following doesn't work. I'm not even sure whether a
subroutine can return an array.

Thanks in advance for any pointers.

Regards,
David Newman

#!/usr/bin/perl

use strict;
use warnings;

my $count = 10;
my @ports;
my $start = 1025;
&spin(@ports);

sub spin {
        for (; $count > 0; $count--) {
                push (@_, $start++);
        }
}

foreach (@ports) {
        print "$_\n";
}





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to