Re: [PATCHv5 08/12] gitweb: auxiliary function to group data
- From
Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
- Date
- Sep 27, 2010, 19:17 UTC
- Message-ID
- <AANLkTinudc8zX33o=vxxo=nf0L9KxFiJR8UYNomMfajN@mail.gmail.com>
- In-Reply-To
- <201009271012.23175.jnareb@gmail.com>
2010/9/27 Jakub Narebski <jnareb@gmail.com>:
Show 27 quoted lines
>>> + 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