Prototypes in Perl are not what you think they are. Leave them out unless you know why you should. Not to mention they're entirely useless here because there is (and can be) no prototype checking on method calls. You can also condense the code significantly.
package gnump3d::oggtagreader; # untested sub new { bless \(undef), shift } sub get_tags { my($self, $filename) = @_; # using lexical filehandles is much safer # die()ing here is probably not the best way to handle failures he +re open(my ($fh), "<", $filename) or return; binmode $fh; read $fh, my ($buffer), 2048; $buffer =~ s/[[:^print:]]/=/g; my %info = map +($_ => /$_=([^=]+)/i), qw(artist title album comment genre tracknumber); $info{track} = delete $info{tracknumber} if exists $info{tracknumber}; return %info; } 1;
It is probably still better to implement something that conforms to the docs (http://reactor-core.org/ogg-tag-standard.html, http://www.xiph.org/ogg/vorbis/doc/v-comment.html).

Makeshifts last the longest.


In reply to Re: Ogg Vorbis tag parsing in pure perl by Aristotle
in thread OGG Vorbis tag parsing in pure perl by skx

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.