in reply to Re: Golf: Length of longest line in a file
in thread Golf: Length of longest line in a file

Excellent.

Please correct me if I am wrong, but the following code ...

$s^=$_

expands to:

$s = $s ^ $_;

So, this takes advantage of the string xor operator's ability to increase the shorter string to match the length of the longer string. Then it returns a string whose length is that of the longer of the 2 strings. (Bitwise String Operators)

Replies are listed 'Best First'.
Re^3: Golf: Length of longest line in a file (explanation)
by BrowserUk (Patriarch) on Jul 04, 2010 at 02:16 UTC

    Correct. |= works also, but not &=.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.