<?xml version="1.0" encoding="windows-1252"?>
<node id="847958" title="Re^2: Golf: Length of longest line in a file" created="2010-07-04 03:03:42" updated="2010-07-04 03:03:42">
<type id="11">
note</type>
<author id="176576">
eyepopslikeamosquito</author>
<data>
<field name="doctext">
&lt;P&gt;
This one gives the same result as [BrowserUk]'s 24 but is two strokes less:
&lt;CODE&gt;
perl -nE "$s^=$_}{say length$s"
perl -lpe "\$Z[y///c]}{$_=@Z"
perl -nE "\$Z[y///c]}{say$#Z"    # update: alternative 22
&lt;/CODE&gt;
Instead of finding the maximum length by exploiting Perl's wonderful bitwise string operator, we instead exploit Perl's marvellous autovivification (exploiting autovivification is common in golf, as was done by Jasper in [id://811919], for example).
&lt;/P&gt;

&lt;P&gt;
For golf historians, notice that the use of &lt;C&gt;y///c&lt;/C&gt; instead of length is known as &lt;I&gt;Abigail's length horror&lt;/I&gt; but was actually first invented by Joseph N Hall in 1996.
And the use of a (one stroke) reference &lt;C&gt;\&lt;/C&gt; to trigger autovivification is known as &lt;I&gt;Thelen's Device&lt;/I&gt; and was invented by Michael Thelen aka [thelenm] in 2002.
This history is discussed in [id://437032].
&lt;/P&gt;
</field>
<field name="root_node">
847747</field>
<field name="parent_node">
847797</field>
</data>
</node>
