Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Removing chars from a word from an array

by ikegami (Patriarch)
on Jan 24, 2006 at 16:05 UTC ( #525215=note: print w/replies, xml ) Need Help??


in reply to Removing chars from a word from an array

Let's try this again!

my $word = 'abracadabra'; my @list = qw( a b c d e ); my %list = map { $_ => 1 } @list; foreach (@list) { delete $list{$_} if $word =~ s/\Q$_//; } @list = keys %list; print("remaining word: ", $word, "\n"); # raaabra print("remaining list: ", @list, "\n"); # e
outputs
remaining word: raaabra remaining list: e

If you wish to replace all intances of the characters in @list, replace s/\Q$_// with s/\Q$_//g. The output would then be the following for the above snippet:

remaining word: rr remaining list: e

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (1)
As of 2022-01-29 10:41 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?