Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Removing chars from a word from an array

by GrandFather (Saint)
on Jan 24, 2006 at 21:35 UTC ( #525321=note: print w/replies, xml ) Need Help??


in reply to Removing chars from a word from an array

Parts of the following may get you where you want to go:

use strict; use warnings; my $word = 'committee'; my @list = qw(t r e e); my %remove; $remove{$_}++ for @list; for my $letter (keys %remove) { --$remove{$letter} while $remove{$letter} and $word =~ s/$letter// +; } #rebuild list @list = (); for my $letter (keys %remove) { push @list, $letter while $remove{$letter}--; } print "Edited word: $word\nEdited list: @list";

Prints:

Edited word: commit Edited list: r

DWIM is Perl's answer to Gödel

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://525321]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (1)
As of 2022-01-29 02:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (74 votes). Check out past polls.

    Notices?