Aimal Pashtoonmal wrote:
> Hi,
>
> Does anyone know how I can go about introducing a single random
> deletion. I have file containing blocks of alphabet each block with a
> uniq tag. I have passed this into a hash where the tags are the keys
> and values are the blocks. Is there a quick and easy way to randomly
> remove a single letter from each block. For exmple:
>
> QWERTYUIOPLKJHGFDSAZXCVBNM
> WAZWSXEDCRFVTGBYHNUJMIKLOP
> DRFGTYHJUIKOLPNMHYTREFWQER
>
> I would want to remove a single letter but not at the same point for
> each block.
It seems a strange thing to want to do! But this should do the trick.
Cheers,
Rob
#perl
use strict;
my @string = qw(
QWERTYUIOPLKJHGFDSAZXCVBNM
WAZWSXEDCRFVTGBYHNUJMIKLOP
DRFGTYHJUIKOLPNMHYTREFWQER);
foreach my $str (@string) {
print "Old: $str\n";
substr ($str, rand (length $str), 1) = "";
print "New: $str\n\n";
}
__END__
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]