Venerable Monks,

I am using MP3::Tag for a very simple operation: parsing the id3v2 tag format into a %02d format for use with id3v1, like so:

#!/usr/bin/perl use warnings; use strict; use Data::Dumper; use MP3::Tag; my $filename = $ARGV[0]; die "Usage: $0 filename" unless $filename; my $mp3 = MP3::Tag->new($filename); $mp3->get_tags(); my $id3v1 = $mp3->{ID3v1} if exists $mp3->{ID3v1}; my $id3v2 = $mp3->{ID3v2} if exists $mp3->{ID3v2}; # Convert id3v2 track format to id3v1 my $track = $id3v2->track; $track = sprintf( "%02d", (split(/\//, $track))[0] ); $id3v1->track($track); $id3v1->write_tag();

Dumping $id3v1 right before the write_tag function shows the track field populated with "01". Dumping the tag after the write shows "1". I have torn apart both MP3::Tag and MP3::Tag::ID3v1 and I just cannot find anything that is truncating this data, althought MP3::Tag does refer to it:

2-digit numbers, or I<number1/number2> with number1,2 up to 999 are allowed for the track number (the leading 0 is stripped);

I just can't find where that is actually implemented! Can anyone help me?


In reply to MP3::Tag - Leading zeros on 'track' truncated by initself

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.