> From: Peter Makholm <[EMAIL PROTECTED]>
> Date: Mon, 08 Apr 2002 13:08:07 +0200
> 
> Lars Henrik Mathiesen <[EMAIL PROTECTED]> writes:
> 
> > map!s/$
> > ^/ /m|//||print,sort%%for map$%{_,sort/./g}.=$_,sort<>
> >
> > If the unnecessary $ at the end of line 1 hadn't snuck in, it would
> 
> Argh. I wasn't really awake at the moment.
> 
> Can anyone explain to me why 's/\n^/ /m' seems to work but s/$\n/ /m'
> doesn't?

Because /\$\n/m will match the single \n at the end of the string, and
/\n^/m won't. And that's the whole point, of course.

> BTW: I'm glad you got rid of %:: it was ugly and confused me for a
> long time.

Very true. But I didn't find any built-in arrays with single character
names and at least 14 elements. (Note: the rules do say that you only
have to handle anagram sets up to 15. My final solution ended up
iterating once for each input line, which is not very efficient ---
there should be a loop exit when it doesn't find any more newlines to
turn into spaces).

Lars Mathiesen (U of Copenhagen CS Dep) <[EMAIL PROTECTED]> (Humour NOT marked)

Reply via email to