physi has asked for the wisdom of the Perl Monks concerning the following question:
Ok this code should delete all multiple chars in $secret. The result is in $newsecret afterwards.my %sec; my $newsecret; for my $char (split //, $secret){ next if exists $sec{$char}; $newsecret .= $char; $sec{$char}++; }
Now I tried it with a map-Statement:
But what has to be written into the { } part ?$newsecret = join '', map { ??? } split //, $secret;
But that results in numberfilled array $newsearch string.my $newsecret = join '', map { my $char=$_; $_='' if exists $sec{$_}; +$sec{$char}++} split //, $secret;
Any ideas ? Thanks
----------------------------------- --the good, the bad and the physi-- -----------------------------------
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: get it into one line ?
by athomason (Curate) on Apr 16, 2001 at 13:49 UTC | |
|
Re: get it into one line ?
by repson (Chaplain) on Apr 16, 2001 at 14:40 UTC | |
|
Re: get it into one line ?
by Eureka_sg (Monk) on Apr 16, 2001 at 14:54 UTC |