views:

72

answers:

2

Okay .. this works ...

sub getApSrvs
{
my %apsrv;
my $cluster;

  foreach $cluster (getClusters())
  {
  $apsrv{$cluster} = [split('\s+', `/$cluster/bin/gethosts -t app|sort -u`)];
  }
return %apsrv;
}

... now how in the ham sandwich do I get this to print like so $cluster --> $hostname

okay I added :

my %apsrv = getApSrvs();
for my $cluster (keys %apsrv) {
print "$cluster -> $apsrv{$cluster}\n";
}

and I get ...

qboc22 -> ARRAY(0x9111618)

qboc5 -> ARRAY(0x9111504)

qboc32 -> ARRAY(0x90e20cc)

qboc28 -> ARRAY(0x90e1d28)

qboc30 -> ARRAY(0x90e1f38)

qboc23 -> ARRAY(0x9111540)

qboc27 -> ARRAY(0x911181c)

qboc29 -> ARRAY(0x91115ac)

qbo -> ARRAY(0x90e2294)

A: 
my %apsrv = getApSrvs();
for my $cluster (keys %apsrv) {
    print "$cluster -> $apsrv{$cluster}\n";
}

You will want to sort the keys (sort keys %apsrv) before printing if the order is important.

Dave Hinton
+2  A: 

$apsrv{$cluster} is a reference to an array, so if you want to print the contents of it you can do :

my %apsrv = getApSrvs();
for my $cluster (keys %apsrv) {
    print "$cluster -> ", join(', ', @$apsrv{$cluster}), "\n";
}
M42