rgammon51 has asked for the wisdom of the Perl Monks concerning the following question:

The documentation for this module tells us to call the routine new() with several parameters to initialize several variables used in the module.

The parameter of interest is -seconds.

The literals "-seconds" and "mm:ss" are accepted without error, yet return 346 seconds for average and 5356 seconds for total time. This is unformatted output.

This should not be difficult, yet I do not understand what the documentation is asking me to do.

This is my reintroduction to Perl. Twenty years ago, I was doing some minor Perl programming on Solaris for Sparc.

Perl version is 5.15.9 on Ubuntu 12.04 for x86.

Replies are listed 'Best First'.
Re: CPAN module MP3::M3U::Parser question
by Corion (Patriarch) on Apr 22, 2012 at 13:45 UTC

    How exactly are you calling MP3::M3U::Parser? Please show the relevant code, even better if it is a self-contained program.

    I interpret the documentation that ->new expects to be called like:

    my $parser = MP3::M3U::Parser->new( -seconds => 'mm:ss', );

    ... but I have no convenient way of testing things at this time.

      #!/usr/bin/perl use strict; use warnings; use MP3::M3U::Parser; # use Data::Dumper; print "Read MP3 Test file \n"; my $parser = MP3::M3U::Parser->new(-seconds => 'mm:ss'); $parser->parse("/home/rgammon51/Documents/Playlist.m3u")->export (-ove +rwrite => 1); my $result = $parser->result; my %info = $parser->info; printf "Number of Songs in this list :: %s\n ", $info{songs}; printf "Total Time to play all songs :: %s\n ", $info{ttime}; printf "Average Time of all songs :: %s\n ", $info{average};

      This ending part does not generate mm:ss results The formatted time only appears in the html file.

      My goal, ultimately, is to use this module to generate a shell script to update the contents of my mp3 player that I carry around daily. it is a cheap player that does not implement shuffle, so I must update its contents periodically with new material, and most importantly in a different order.

      This code uses your hint as to how to proceed. however, the screen output from printf is just seconds, not hh:mm:ss.

      This appears to be a characteristic of the code in the CPAN module, and to change it, I must modify the source.