From: Giuseppe Bilotta Date: Mon, 27 Sep 2010 19:17:49 GMT Subject: Re: [PATCHv5 08/12] gitweb: auxiliary function to group data Message-ID: In-Reply-To: <201009271012.23175.jnareb@gmail.com> 2010/9/27 Jakub Narebski : >>>  +     if (ref($content) eq 'CODE') { >>>  +             $content->(); >>>  +     } elsif (ref($content) eq 'ARRAY') { >>>  +             print @$content; > > The 'ARRAY' part is probably unnecessary overengineering. > >>>  +     } elsif (!ref($content) && defined($content)) { >>>  +             print $content; >>>  +     } > > Or even (in the vein of further overengineering) > >    +     } elsif (ref($content) eq 'SCALAR') { >    +             print esc_html($$content); >    +     } elsif (!ref($content) && defined($content)) { >    +             print $content; >    +     } > > or vice versa ;-) > >>> >>> Well, $content could be also open filehandle... > > Though I don't know how to check that.  ref on filehandles return > 'GLOB'... well, we can use 'openhandle' from Scalar::Util (core). > But that is probably unnecessary overengineering. I have made cases for closures, scalar refs and scalar values. I've also added a case for GLOB or IO::Handle to allow a file handle to be passed as either *handle or *handle{IO}. I've also added a comment block explaining the syntax better. -- Giuseppe "Oblomov" Bilotta