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

Re: [MacPerl] FNG



<x-flowed>At 16:02 -0500 1/27/99, Chris Nandor wrote:
>  $w = (/a/);
...
> 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.

You cheated.  You tested with /a/ (aka m/a/).
We have been discussion the return value of the substitution command s/a/.

Anyway, the camel sez that s/...
   returns the number of substitutions made (on success)
   returns false (0) otherwise

the camel says that m/...
   returns true (1) or false("") in a scalar context, depending upon 
the success of the match.
   In list context, m/... returns a list of the (parenthesized) 
subexpressions of the pattern (aka $1, $2, $3...) upon success, a 
null list upon failure, and (1) if the match suceeds but there were 
no parentheses in the pattern.

Considering that false is false but "" is not precisely equivalent to 0
we can't use the result from a match (m/.../) to experiment with how 
substitution works (s/.../).
---
      |\      _,,,---,,_       Vicki Brown <vlb@cfcl.com>
ZZZzz /,`.-'`'    -.  ;-;;,_   Journeyman Sourceror: Scripts & Philtres
     |,4-  ) )-,_. ,\ (  `'-'  P.O. Box 1269  San Bruno  CA  94066
    '---''(_/--'  `-'\_)       http://www.cfcl.com/~vlb  www.ptf.com/macperl

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


</x-flowed>