Any ideas?
[perl]
foreach $c (keys %config) {
if ($new =~ /$c/) {
print "not adding $c to hash\n";
$c++; }
else { %hash = (%hash, $new, 1);
print "added $new to hash\n";}
$c++; } #ending the foreach $c loop
[/perl]
If the obect is to just add $new to the hash if there is not a key that is like it already:
my $found = 0;
foreach my $c ( keys( %hash ) ) {
$found = 1 if ( $new =~ $c );
}
$hash{ $new } = 1 unless $found;
$hash{ $new } = 1 unless ( grep( /$new/, keys( %hash ) );
$hash{ $new } = 1 unless ( defined ( $hash{ $new } ) );