in reply to Difference Of Two Strings
Updated to more accurately reflect the requirements :-)my $str="abcd"; my $letters = "ab"; print not_in($str, $letters),"\n"; sub not_in { my $str = shift; my $letters = shift; my (%hash1, %hash2); my @arr1 = split //, $str; @hash1{@arr1} = @arr1; my @arr2 = split //, $letters; my @deleted = grep $_, delete @hash1{@arr2}; @hash2{@arr2} = undef; delete @hash2{@deleted}; return if %hash2; join '', keys %hash1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Difference Of Two Strings
by YuckFoo (Abbot) on Nov 03, 2001 at 05:13 UTC |