I am writing a wma to mp3 converter, which preserves tags by using Audio::WMA and MP3::Tag

towards the end of the code, I have this:

$mp3->update_tags( $mp3_tags ); # write tags to tmp.mp3 . . copy( 'tmp.mp3', $target);

(I am using File::Copy copy because some files have all kinds of quotes and so on which make backticks, system, etc awkward. I guess I could have escaped them, but I went this way instead ... that's what modules are for, right?)

Here's the weird thing. My target file (in this case test.mp3) doesn't have tags, but tmp.mp3 does. the files are also a bit different in size:

root@trekulbollox:~/convert_wma# ls -l total 57864 -rwxr-x--- 1 root root 2595 2011-10-31 03:37 convert_wma.pl -rw-r--r-- 1 root root 0 2011-10-31 03:37 errors -rwxr-xr-x 1 root root 9913921 2011-10-31 03:01 original.wma -rw-r--r-- 1 root root 24627199 2011-10-31 03:38 test.mp3 -rw-r--r-- 1 root root 24627327 2011-10-31 03:38 tmp.mp3 root@trekulbollox:~/convert_wma# id3v2 -l tmp.mp3 id3v1 tag info for tmp.mp3: Title : Big Foot Artist: Stephen Riley Album : Easy to Remember Year: 2007, Genre: Jazz (8) Comment: Track: 2 tmp.mp3: No ID3v2 tag root@trekulbollox:~/convert_wma# id3v2 -l test.mp3 test.mp3: No ID3 tag

There is really nothing between the writing of tags and the copy that can do this. Is it possible that there is some kind of weird timing issue, where the tag is not flushed to the file before the copy happens?

I am sitting here thinking this must be a late night issue ... but there are no file operations at all between the two points. What is going on ... ?


In reply to strange File::Copy issue by danmcb

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.