http://qs321.pair.com?node_id=460966


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