[Bps-public-commit] r18319 - in Net-Google-Code/branches/write: .

sunnavy at bestpractical.com sunnavy at bestpractical.com
Tue Feb 10 07:46:07 EST 2009


Author: sunnavy
Date: Tue Feb 10 07:46:07 2009
New Revision: 18319

Modified:
   Net-Google-Code/branches/write/   (props changed)
   Net-Google-Code/branches/write/lib/Net/Google/Code/Role/HTMLTree.pm

Log:
 r19748 at sunnavys-mb:  sunnavy | 2009-02-10 20:20:57 +0800
 return captures when possible for method html_contains


Modified: Net-Google-Code/branches/write/lib/Net/Google/Code/Role/HTMLTree.pm
==============================================================================
--- Net-Google-Code/branches/write/lib/Net/Google/Code/Role/HTMLTree.pm	(original)
+++ Net-Google-Code/branches/write/lib/Net/Google/Code/Role/HTMLTree.pm	Tue Feb 10 07:46:07 2009
@@ -39,9 +39,17 @@
 
     return unless $part;
 
-    return 1
-      if ref $args{as_text} eq 'Regexp' && $part->as_text =~ $args{as_text}
-          || $part->as_text eq $args{as_text};
+    my $text = $part->as_text;
+    return 1 if $text eq $args{as_text};
+
+    if ( ( ref $args{as_text} eq 'Regexp' ) && ( my @captures =
+        $text =~ $args{as_text} ) )
+    {
+# note, if there's no captures at all but the string matches, 
+# @captures will be set to (1), so don't use @captures unless you 
+# know there's some capture in the regex
+        return wantarray ? ( 1, @captures ) : 1;
+    }
     return;
 }
 



More information about the Bps-public-commit mailing list