Kevin Dowd wrote: > $myEmail = 'dowd%40ndirect.co.uk'; > $myEmail = ~ s/%40/@/g; > print "$myEmail"; > > All I get back is 4294967295. Surprising, isn't it? :-) But correct. Excerpt of followup (sent 27 January 1999) by Geoffrey C Kinnel: > 0) There is no string specified to search (because =~ was not used) so > the substitution tries to operate on nothing No, the substitution operates on $_, which in the above program has the undefined value. > 1) the substitution fails, returning a 0 (the number of substitutions) It does not for me. See below. > 2) you assign $myEmail the value of the bitwise negation of 0, > represented as a 32 bit integer [...] which happens to be 4294967295 Agreed. (In hexadecimal this is 0xffffffff, which looks much less random.) ***** Ok, Kevin Kowd's problem is long solved, but leaves me with the subtle question, "What does s/// return on failure?". Not quite 0 ! (I'm using perl, version 5.004_04 built for sun4-solaris, but hope this doesn't matter!) Sure I get the number of substiturions performed when it succeeds. But when it fails, I get a weird kind of empty string. The following program, 1 #! /usr/local/bin/perl -w 2 3 $_ = "no match"; 4 $x = s/%40/@/; 5 $y = ""; 6 $notx = ~$x; 7 $noty = ~$y; 8 $str_equal = $x eq $y; 9 $num_equal = $x == $y; 10 11 print "'$x', '$y', $str_equal, $num_equal, '$notx', '$noty'\n"; warns me that Argument "" isn't numeric in eq at line 9, and prints '', '', 1, 1, '4294967295', '' Huh? Both $x and $y contain the empty string, they are equals as strings and numerically, but the bitwise negation operator works differently on them! I would have expected bitwise flip of all characters in a string, as it happens for $y. But $x, the result of the substitution, seems slightly more numeric than the genuine string $y. Note that line 9 chages $y !! After the comparison, ~$y would evaluate to 4294967295, no longer "". BTW, the warning was about $y, not $x. Perl thinks there is no side effect, and documents its belief with the warning to the following program: $x = "1234"; print ~$x, "\n"; $x+12; print ~$x, "\n"; I get: Useless use of addition in void context at -e line 2. лкни 4294966061 First, $x is a string. Then it is a number. My question: How many kinds of "scalars" exist? Christian Brechbuehler Communication Technology Laboratory, Image Science Group Swiss Federal Institute of Technology (ETH), Zurich ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch