On Thu, May 16, 2002 at 01:24:39PM -0400, [EMAIL PROTECTED] wrote:
> here is a little plugin i wrote that others may find useful.

Cool!  

Couple of suggestions for the code:

>sub new {
>    my $class = shift;
>    my $context = shift;
>    # dereference the arguments if necessary
>    my @files = map { ref($_) eq 'ARRAY' ? @{$_} : $_ } @_;
>
>    my @info = map {
>       $_ = $_->{path} if ref eq 'Template::Plugin::File';
>       my $i = image_info($_);
>       $i->{path} = $_;
>       ($i->{name}) = /.*\/(.*)$/; # yikes this will only do Unix
                               
File::Basename will do it for all platforms.
                           
>    # is there a better way to
>    # fold single element arrays?
>    my $ref;
>    if (scalar(@info) <= 1) {
>       $ref = shift @info;
>    } else {
>       @$ref = @info;
>    }

You could do something like:

    return scalar @info > 1 ? \@info : shift @info;

Cheers
A



Reply via email to