In a message dated 28 Aug 2002, Aaron Sherman writes:
> Ok, just to be certain:
>
>       $_ = "0";
>       my $zilch = /0/ || 1;
>
> Is $zilch C<"0"> or 8?

8?  How do you get 8?  You'd get a result object which stringified was "0"
and booleanfied was true.  So here, you'd get a result object vaguely
isomorphic to "0 but true".

> If C<"0">, does it continue to be "true"? What about:
>
>       $_ = "0";
>       my $zilch = /0/ || 1;
>       die "Failed to match zero" unless $zilch;
>
> Is that a bug?

Yes, it's a bug, as I don't see any way to actually die there.  I don't
understand the presence of the C<|| 1> there.  I think you'd just write
C<my $zilch = /0/;>.  If you really truly wanted it to be one if it
failed, but you still wanted the die to work, you'd write:

  $_ = "0";
  my $zilch = /0/ || 1 but false;
  die "Failed to match zero" unless $zilch;

Or, more comprehensibly, just

  $_ = "0";
  my $zilch = /0/
               or die "Failed to match zero";

Trey

Reply via email to