switch to map as a collection method - thanks to jnthn (and good luck with rakudo...
Matt S Trout [Thu, 22 Oct 2009 18:40:30 +0000 (14:40 -0400)]
examples/bloggery/bloggery.cgi

index 6e12e79..cef1f9b 100755 (executable)
@@ -1,5 +1,3 @@
-#!/usr/bin/perl
-
 use FindBin;
 use lib $FindBin::Bin.'/code';
 use Web::Simple 'Bloggery';
@@ -28,6 +26,11 @@ sub post {
   return Bloggery::Post->from_file($file);
 }
 
+sub map {
+  my ($self, $code) = @_;
+  map $code->($_), $self->all;
+}
+
 package Bloggery::Post;
 
 sub from_file {
@@ -140,13 +143,13 @@ sub main_html_for {
     $data->html
   } elsif ($data->isa('Bloggery::PostList')) {
     <ul>,
-      (map {
+      $data->map(sub {
         my $path = '/'.$_->name.'.html';
         <li>,
           <h4>, <a href="$path">, $_->title, </a>, </h4>,
           <span class="summary">, $_->summary_html, </span>,
         </li>;
-      } $data->all),
+      }),
     </ul>;
   } else {
     <h2>, "Don't know how to render $data", </h2>;