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


in reply to regular xpression stuff

In this case, you don't want a regex, at least directly. I think we've golfed this once, but in general:
my $to_be_matched = 'tab'; my $word = 'bat'; if ( join '', sort split(//, $word) eq join '', sort split(//, $to_be_matched ) ) { # Success! } else { # Failure }

Update - $ instead of @ on to_be_matched

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important

Replies are listed 'Best First'.
Re: Re: regular xpression stuff
by screamingeagle (Curate) on Jan 21, 2002 at 04:30 UTC
    shouldnt
    if ( join '', sort split(//, $word) eq join '', sort split(//, $to_be_matched ) ) {
    be
    if ( join('', sort split(//, $word)) eq join('', sort split(//, $to_be +_matched)) ) {
    (extra parenthesis added )

    After adding the parenthesis , i get "Success" (i.e. "bat" = "tab" based on your example), without them the result is "Failure"