in reply to Re: Re: (Golf) Anagram Finder
in thread (Golf) Anagram Finder

@{pop} doesn't work as you intended, because it refers to the plain old array @pop. The parentheses in @{pop()} make it into an expression, which is evaluated.

However, you could save a character by using a plus instead, as in @{+pop}.

Update: But, if you wanted to save even more characters... :)

sub anagram { grep"@{[sort$_[0]=~/./g]}"eq"@{[sort/./g]}",@{+pop} }
51 characters.

Replies are listed 'Best First'.
Re^4: (Golf) Anagram Finder
by tadman (Prior) on Aug 04, 2001 at 18:49 UTC
    The @{[func]} method for inserting the result of an arbitrary function call into a string is amazing. Someone once asked if they could put subroutine calls into a double-quoted string and have them expand properly, but I don't think anyone gave a satisfactory answer.

    I had no idea that the double-quoted string parser was so robust.
Re^4: (Golf) Anagram Finder
by Sartak (Hermit) on Jul 26, 2006 at 18:38 UTC
    If you lift the requirement that you have to compare one word to many, you can get the following (which returns whether its two arguments are anagramic)
    sub anagram { @_=map{join"",sort/./g}@_;pop eq pop }
    36 characters.