Rob Dixon wrote:
> > 2. why do i get this message when i finally do get to an image:
> > Not a CODE reference at ./bigimg2.pl line 39.
> > (this is displayed once an image is found)
> >
> > and line 39 states:
> >         $type        =    $info->(file_ext);    # three letter image
> > type
>
> You are using the wrong sort of brackets. Parentheses mean that
> $info must be a code reference, whereas it is actually a hash
> reference whish needs braces around the key value:
>
>     $type = $info->{file_ext}

Sorry, I didn't explain this very well. If you had a subroutine
reference, like:

    sub double {
        my $param = shift;
        return $param + $param;
    }

    my $subref = \&double;

you could call it like this:

    my $answer = $subref->(7);

which does exactly the same thing as

    my $answer = double(7);

The parentheses are telling Perl that this is the parameter
to a subroutine call, rather than the index of an array
reference or the key of a hash reference, which use
[ .. ] and { .. } respectively. You were using a hash
reference in this position, and Perl complained that it
couldn't execute a hash for you!

HTH,

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to