blazar has asked for the wisdom of the Perl Monks concerning the following question:

While answering to Counting the number of items returned by split without using a named array, I did a little experiment, i.e.

$ perl -wlne '$x=split'

but for some strange reason on the first try I used double quotes instead of single ones (I'm under *NIX). So it was just like s/$x// and thinking of it retrospectively I would have thought it to cause a syntax error. But it seems that assignement into nothing is valid:

$ perl -MO=Deparse -Mstrict -wlne '=split' BEGIN { $^W = 1; } BEGIN { $/ = "\n"; $\ = "\n"; } LINE: use strict 'refs'; while (defined($_ = <ARGV>)) { chomp $_; } -e syntax OK

it just silently evaporates... wouldn't it be the case to issue at least a warning instead? Or are there good reasons not too! Offhand I can't think of any incompatibility with wanted beahaviour...

Replies are listed 'Best First'.
Re: Unary equal?
by rhesa (Vicar) on May 03, 2006 at 10:51 UTC
    My guess is that =split is interpreted as a POD tag, and discarded for that reason.
      <slaps his="forehead">
      Indeed. Sorry!
      </slaps>