[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] FNG



At 15.41 -0500 1999.01.27, Geoffrey C Kinnel wrote:
>> >  1) the substitution fails, returning a 0 (the number of substitutions)
>>
>> It does not for me.  See below.
>
>Yes is does. See below :).

No, it doesn't.  :)

>$x = int(s/%40/@/);
>
>When forced to an integer context, it is 0. So when Perl needs an
>integer, it makes an integer out of that value, though it may be null in
>a string context. The scalar is defined, but null. In an integer
>context, that's 0, in a string context, that's null (or'').

Well, not really.

  #!perl -wl
  $w = (/a/);
  $x = undef;
  $y = '';
  $z = 0 + '';
  for ($w, $x, $y, $z) {
    printf "%s => %s\n", $_, ~$_;
  }

Ignoring warnings, we get:

   => 4294967295
   =>
   =>
  0 => 4294967295

If $w contained the null string (or undef), it would not have printed
2**32-1 for ~$_.  But if it contained 0, then it would not have printed
nothing for $_.  0 clearly is not returned.  The null string clearly was
not returned.  My best guess is that it is some other kind of null, a null
number.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch