Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Unique List of Common Characters Between Two Strings

by de-merphq (Beadle)
on Jan 11, 2005 at 19:53 UTC ( #421397=note: print w/replies, xml ) Need Help??


in reply to Unique List of Common Characters Between Two Strings

Since you throw away the hash I think you can simplify the grep a little:

grep $u{ $_ }-- >0, split //, $str
---
alter ego of demerphq

Replies are listed 'Best First'.
Re^2: Unique List of Common Characters Between Two Strings
by Limbic~Region (Chancellor) on Jan 11, 2005 at 19:56 UTC
    de-merphq,
    ...I think you can simplify the grep a little

    I thought about that too at first but it is flawed thinking. If a letter appears more than once then it can go from 0 to a negative number which will again start returning true values. The intention was to only produce a unique list.

    Cheers - L~R

      Yeah sorry, the >0 should be there.. (i updated.)

      ---
      alter ego of demerphq

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2023-04-01 08:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?