hello monks,

today i was trying to get Image::Size::imgsize working. i'm using a framework that does a use encoding 'utf8' at the beginning. imgsize() called on a jpeg didn't return the size but said it couldn't find out the image type.
i made up a simple reproducing script which shows that removing the use encoding fixes this:

# image.pm: package image; use strict; use warnings; use Image::Size (); my $img = "/tmp/test.jpg"; no encoding; # this doesn't help my ($x, $y, $i) = Image::Size::imgsize($img); print "$x,$y, $i\n"; 1; # image.pl: #!/usr/bin/perl use strict; use warnings; # comment out next line to get it working use encoding "utf8"; use image;

next i found out was that Image::Size is using AutoLoader.pm, and moving the jpegsize.al code into the module fixed it too. so this only seems to happen with files loaded with AutoLoader. i tried debugging jpegsize.al a bit and found out that there is a call of ord() in the subroutine that returns the correct value normally, but with use encoding 'utf8' it returns 65533 always.

so i'm not sure what happens there, but encoding.pm seems to change the way how .al files work with filehandles.
i tried Devel::Peek to get more information but the strings all looked okay.
now i wonder if this is a bug in AutoLoader.pm, or if it's the way encoding.pm is used by me.

i would be glad for any hints.

update: moving the use encoding after use image fixes it, too (but this can't be a general solution).

update2: tried with perl 5.8.4 and 5.8.8


In reply to use encoding 'utf8' and AutoLoader by tinita

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.