SPUG: double-dot stylin'

Yitzchak Scott-Thoennes sthoenna at efn.org
Thu Apr 22 10:47:07 CDT 2004


On Thu, Apr 22, 2004 at 07:17:19AM -0700, "Michael R. Wolf" <MichaelRWolf at att.net> wrote:
> Unfortunately this minimal version didn't work
> 
>     push 1 .. /^\s*$/ ? @header : @body, $_ while (<>);

I think this has come up here before.
The way to get this to work is:
   push @{ 1 .. /^$/ ? \@header : \@body }, $_ while (<>);

The "push expr ? @array1 : @array2" form *does* work when expr is a
constant or expression over only constants, but this is a bug and
should not be relied upon.

When you teach people about .. it is a good idea to mention the
implicit comparison with $.



More information about the spug-list mailing list