in reply to Multi-Word Anagrams

Unfortunately it doesn't quite work:
Can't use an undefined value as an ARRAY reference at ./multi-word-ana +grams line 99.

Replies are listed 'Best First'.
Re: Re: Multi-Word Anagrams
by jweed (Chaplain) on Oct 28, 2003 at 05:02 UTC
    I had the same problem as A.M. above, but changing @{ +shift } to @{ shift @_ } in ln. 99 (last line of expand subroutine) does the trick (@_ is necessary b/c @{ shift } is interpreted as @shift). ;)
      That's odd. @{ +shift } should be the same as @{ shift(@_) }. What version of Perl mistook it for @shift?

      _____________________________________________________
      Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
      s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

        well, the arry deref wasn't working so I removed the plus sign just to see if it would do anything. That code - @{ shift } - was mistaken to be @shift. Adding the explicit argument list seemed to work. This is under WinMe, perl 5.8.0. I haven't tried it on Linux yet (frankly, I can't see how this would make a difference but, *shrug* you never know). What did you test on? B/c it seems to work for 2 people and not work for 2...
Re: Re: Multi-Word Anagrams
by japhy (Canon) on Oct 27, 2003 at 21:10 UTC
    Could you explain how you got that error?

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

      Of course: I copy-and-paste your script, save the file, make it executable and - boom! - as I try to use it, the problem occurs. I don't change anything...
        How did you run it? What arguments did you use? Do you have a dict file in the location the script looks for it (/usr/dict/words)?

        _____________________________________________________
        Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
        s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;