File::Spec 0.82 beta
[p5sagit/p5-mst-13.2.git] / lib / overload.pm
index bcb56c3..ba96bc9 100644 (file)
@@ -1,5 +1,7 @@
 package overload;
 
+$overload::hint_bits = 0x20000;
+
 sub nil {}
 
 sub OVERLOAD {
@@ -87,7 +89,7 @@ sub AddrRef {
 }
 
 sub StrVal {
-  (OverloadedStringify($_[0])) ?
+  (OverloadedStringify($_[0]) or ref($_[0]) eq 'Regexp') ?
     (AddrRef(shift)) :
     "$_[0]";
 }
@@ -113,9 +115,9 @@ sub mycan {                         # Real can would leave stubs.
 
 %ops = ( with_assign     => "+ - * / % ** << >> x .",
         assign           => "+= -= *= /= %= **= <<= >>= x= .=",
-        str_comparison   => "< <= >  >= == !=",
+        num_comparison   => "< <= >  >= == !=",
         '3way_comparison'=> "<=> cmp",
-        num_comparison   => "lt le gt ge eq ne",
+        str_comparison   => "lt le gt ge eq ne",
         binary           => "& | ^",
         unary            => "neg ! ~",
         mutators         => '++ --',
@@ -129,7 +131,7 @@ sub constant {
   # Arguments: what, sub
   while (@_) {
     $^H{$_[0]} = $_[1];
-    $^H |= $constants{$_[0]} | 0x20000;
+    $^H |= $constants{$_[0]} | $overload::hint_bits;
     shift, shift;
   }
 }
@@ -396,9 +398,9 @@ A computer-readable form of the above table is available in the hash
 
  with_assign     => '+ - * / % ** << >> x .',
  assign                  => '+= -= *= /= %= **= <<= >>= x= .=',
- str_comparison          => '< <= > >= == !=',
+ num_comparison          => '< <= > >= == !=',
  '3way_comparison'=> '<=> cmp',
- num_comparison          => 'lt le gt ge eq ne',
+ str_comparison          => 'lt le gt ge eq ne',
  binary                  => '& | ^',
  unary           => 'neg ! ~',
  mutators        => '++ --',
@@ -1029,7 +1031,7 @@ circumscribed octagon using the above package:
   my $iter = 1;                        # 2**($iter+2) = 8
   my $side = new symbolic 1;
   my $cnt = $iter;
-  
+
   while ($cnt--) {
     $side = (sqrt(1 + $side**2) - 1)/$side;
   }
@@ -1154,7 +1156,7 @@ Use this module like this:
   my $iter = new symbolic 2;   # 16-gon
   my $side = new symbolic 1;
   my $cnt = $iter;
-  
+
   while ($cnt) {
     $cnt = $cnt - 1;           # Mutator `--' not implemented
     $side = (sqrt(1 + $side**2) - 1)/$side;