Sophia, et al
> If you know in advance the array index then use splice.
If you know only the value you want to remove (and you like map...):
#/usr/bin/perl -w
use strict;
my %compilers = (
 system1 => ['compiler_a'],
 system2 => ['compiler_b', 'compiler_c','compiler_d'],
 system3 => ['compiler_e'],
 system4 => ['compiler_f'],
 system5 => ['compiler_g', 'compiler_h','compiler_i', 'compiler_k'],
 system6 => ['compiler_l'],
);
my ($h, $i, $j, $k, @ok);
$j = 0;
show();
print "Enter the number associated with the element you want to remove\n";
while (<>) {
 chomp;
 $h = $_;
 unless (/\d+/) {print"Try again\n"; next}
 unless ($h < $j and $h >= 0) {print"Try again\n"; next}
 last if defined $h;
}
@ok = map { $_ } ( map { @{ $compilers{$_} } } keys %compilers );
map { my $key = $_;
   my $z = 0;
   map { $k = $key, $i = $z++ if $ok[$h] eq $_ } @{ $compilers{$key} };
 } keys %compilers;
$j = splice @{ $compilers{$k} }, $i, 1 if defined $k and defined $i;
print" Element removed: $j\n";
$j = 0;
show();
sub show {
 print map { $j++." -> $_\n" } ( map { @{ $compilers{$_} } } keys
%compilers );
}

David



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

Reply via email to