note
eyepopslikeamosquito
<P>
<blockquote>
<CODE>
for($/)x16
</CODE>
<I>
A slick way of getting the newline (vis-à-vis -l print until...)!
Changing the loop to for($_)x16 is informative.
And, since a bare print prints both $_ and $/, I found it rather unobvious which variable holds the strings.
</I>
</blockquote>
Actually, <C>$/</C> is the <I>input</I> record
separator, so a bare print does not print it.
What's being printed is just the (localized) <C>$_</C>
inside the for loop.
Of course, a bare print will print <C>$\</C>, aka the output
record separator, often seen in golf,
as in, for example, [id://759963].
</P>
<P>
The <C>for($/)x16</C> loop aliases <C>$/</C> and,
despite the <C>x16</C>, only the single <C>$/</C> value
is (repeatedly) changed, as you will discover by printing it
after the loop has terminated.
Replacing "print" with "warn" like so:
<CODE>
s/^|\d+/$&+$'||1/eg,warn("du='$_' ds='$/'\n"),s// /for($/)x16;
warn("at end du='$_' ds='$/'\n");
</CODE>
should clarify.
BTW, this eccentric "for loop aliasing" trick is
often seen in golf; see, for example, [id://903641]
in the "Bottle Golf Tip No 2" section (search for
Cantor).
Finally, the "for loop aliasing" trick is a specific
example of Eugene van der Pijll's general golfing mantra,
<I>"Can't possibly work, let's try it anyway"</I>. :)
</P>
940559
940909