make XML::Tags return scalarrefs
Matt S Trout [Wed, 21 Oct 2009 18:01:21 +0000 (14:01 -0400)]
lib/XML/Tags.pm
t/tags.t

index 480fefc..1b2729c 100644 (file)
@@ -43,7 +43,7 @@ sub _find_target {
         # unless it smells like </foo> or <foo bar="baz">
         return File::Glob::glob($_[0]) unless (/^\/\w+$/ || /^\w+\s+\w+="/);
       }
-      return '<'.$_[0].'>';
+      return \('<'.$_[0].'>');
     };
   }
 }
@@ -52,7 +52,7 @@ sub _export_tags_into {
   my ($class, $into, @tags) = @_;
   foreach my $tag (@tags) {
     no strict 'refs';
-    tie *{"${into}::${tag}"}, 'XML::Tags::TIEHANDLE', "<${tag}>";
+    tie *{"${into}::${tag}"}, 'XML::Tags::TIEHANDLE', \"<${tag}>";
   }
   return sub {
     foreach my $tag (@tags) {
index 4f9807b..e80d2b7 100644 (file)
--- a/t/tags.t
+++ b/t/tags.t
@@ -22,12 +22,12 @@ use Test::More qw(no_plan);
 
   sub quux {
     use HTML::Tags;
-    <html>, <body id="spoon">, "YAY", </body>, </html>;
+    <html>, <body id="spoon">, \"YAY", </body>, </html>;
   }
 }
 
 is(
-  join(', ', Foo::foo()),
+  join(', ', map ${$_}, Foo::foo()),
   '<one>, <two>, <three>',
   'open tags ok'
 );
@@ -35,13 +35,13 @@ is(
 ok(!eval { Foo::bar(); 1 }, 'Death on use of unimported tag');
 
 is(
-  join(', ', Foo::baz()),
+  join(', ', map ${$_}, Foo::baz()),
   '</bar>',
   'close tag ok'
 );
 
 is(
-  join('', Foo::quux),
+  join('', map ${$_}, Foo::quux),
   '<html><body id="spoon">YAY</body></html>',
   'HTML tags ok'
 );