Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: string comparison

by davidj (Priest)
on May 27, 2005 at 07:22 UTC ( #460966=note: print w/ replies, xml ) Need Help??


in reply to string comparison

Assuming that strings "match" if they have the same number of comma delimited words, the following will do the trick:

#!/usr/bin/perl use strict; my (%str1, %str2); my $str1 = "~cake,pastry"; my $str2 = "pastry,~cake"; my @str1 = split(",", $str1); my @str2 = split(",", $str2); map { $str1{$_}++ } @str1; map { $str2{$_}++ } @str2; foreach $key (keys %str1) { print "not equal\n" if $str1{$key} != $str2{$key}; }
davidj


Comment on Re: string comparison
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2014-12-20 16:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (96 votes), past polls