http://www.perlmonks.org?node_id=1005415


in reply to Regex to compare (if) two strings (Uniquely - I will explain inside)

Using a regex:
use Modern::Perl; my $randword = join '', ('A'..'Z')[ map rand 26, 1..8 ]; say $randword; say "Make a word with the above characters"; my $word = <>; chomp $word; my $regex = (join '?', sort split '', $randword) . '?'; $word = join '', sort split '', $word; say "Comparing $word with $regex"; if ($word and $word =~ m/^$regex$/i){ say 'OK'; } else { say 'NOT OK'; }

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics