This is a small test program I wrote to test the feasibility of what I want
to do.
Basically if an element in the array exists as a package group in the
hash, the array element be replace with the elements of the package group.
A package group is a hash ( I think its actually a scalar reference to an
anonymous hash ) that does NOT contain the key 'lppname' .
Does anyone see any potential flaws with this solution ?
Any cleaner ways do go about the same thing ?
Cheers,
#!/usr/bin/perl -w
use strict;
my @array = qw(A B Y C D E);
my %hash;
$hash{A} = {
lppname => "A",
};
$hash{B} = {
lppname => "B",
};
$hash{C} = {
Q => "1",
R => "1",
S => "1",
};
$hash{D} = {
lppname => "D",
};
$hash{E} = {
X => "1",
Y => "1",
Z => "1",
};
my @newElements;
print "@array\n";
my $index = 0;
while ( $index <= $#array )
{
if ( not defined $hash{$array[$index]} )
{
print $array[$index]." does not exist.\n";
}
elsif ( not exists $hash{$array[$index]}->{lppname} )
{
print $array[$index]." is a package group.\n";
push @array, keys %{$hash{$array[$index]}};
splice( @array, $index, 1);
}
$index++;
}
print "@array\n";
-----------------------------------------
Craig Moynes
[EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]