Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
The stupid question is the question not asked
 
PerlMonks  

Re: regular xpression stuff

by Masem (Monsignor)
on Jan 20, 2002 at 21:00 UTC ( #140218=note: print w/ replies, xml ) Need Help??


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


Comment on Re: regular xpression stuff
Download Code
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"

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2014-04-17 11:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (446 votes), past polls