Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: regular xpression stuff

by Masem (Monsignor)
on Jan 20, 2002 at 21:00 UTC ( [id://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

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"

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-19 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found