I have these 2 subroutines:
sub _remove_snap {
my ( $vm ) = @_;
# skip if no snapshots on vm
unless ( defined $vm->snapshot ) {
print $vm->name . " has no snapshots, skipping\n";
return;
}
my $snaps = _find_snapname( $vm->snapshot->currentSnapshot,
$vm->snapshot->rootSnapshotList );
print Dumper $snaps;
}
sub _find_snapname {
my ( $ref, $tree ) = @_;
my @snaps;
foreach my $node (@$tree) {
print $node->name, "\t" . $node->createTime . "\n";
if ( $node->name eq $snapname ) {
push @snaps, $node
}
_find_snapname( $ref, $node->childSnapshotList );
}
return \@snaps;
}
And I cannot seem to return the snapshot information from _find_snapname back to _remove_snap. If I print with Dumper at the end of _find_snapname right before the return \@snaps statement, I see the correct info displayed on screen, but when dumping it on the _remove_snap subroutine, then I get an empty $VAR1 = [];
I am obviously missing something obvious, but I do not see it. Any help greatly appreciated.