http://www.perlmonks.org?node_id=341057

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

I am trying to create a Perl script to take a CD, and automatically rip it, encode it, organize the files, and save the data in a database so that I can tell the script to DJ for me. For instance, I want to be able to tell the program to [;ay x hours of music and the percentage of each genre to include. Furthermore, I want it to use Tk, so that it looks cool.

I am running into problems with cdparanoia. When cdparanoia runs, it outputs a very detailed status message to the screen. Is there a way to capture what cdparanoia is sending to the terminal, so that I can read in the data (i.e. the progress), and then use that to update a Tk based status bar?

I thought about redirecting the output of cdparanoia via a pipe to a perl script or something of that nature, but I was wondering if anyone knows of a more elegant way. Also, I already checked CPAN, and the only cdparanoia module I found, POE::Component::CD::Rip doesn't meet my needs.

Many thanks in advance,

Vautrin


Want to support the EFF and FSF by buying cool stuff? Click here.
  • Comment on Creating a Complete Wrapper for a Compiled Program

Replies are listed 'Best First'.
Re: Creating a Complete Wrapper for a Compiled Program
by ccn (Vicar) on Mar 30, 2004 at 19:23 UTC
    You can use IPC::Open2 to control stdin, stdout of an external program, or use IPC::Open3 to control stderr also.
Re: Creating a Complete Wrapper for a Compiled Program
by saintmike (Vicar) on Mar 30, 2004 at 20:20 UTC
    As explained here, using POE along with Tk is a good idea. As for running cdparanoia and dealing with its output, this looks like a job for POE::Wheel::Run.

    -- saintmike

Re: Creating a Complete Wrapper for a Compiled Program
by matija (Priest) on Mar 30, 2004 at 19:24 UTC
    Well, you could open cdparanoia as a pipe:
    open(CD,"cdparanoia .... |") || die "could not open pipe to cdparanoia +";
    Don't forget to turn off the buffering on the filehandle.
Re: Creating a Complete Wrapper for a Compiled Program
by Three (Pilgrim) on Mar 31, 2004 at 20:41 UTC
    Why dont you try a diffrent tact on it.
    Rip all your cd's to mp3 then write a perl program to parse the id3 tags inside the mp3's.
    Here is a link with some modules that might help.