Question one: Is there anyway i could easily start/stop a process from perl?
Isn't the problem that you don't know the pid to kill?
Just a suggestion - maybe it would be easier to have perl streaming the current mp3 to a fifo, and have mpg123 play that? See the .signature example in perlipc for a working example.
Question two: Is there anyway to convince perl to read/write mp3 files without dying
You were already on the right track :)
Here's an example of what I meant in 199077: adam@2cb:~$ perl -e 'open F, "nofx - falling in love.mp3"; binmode F;
+open G, ">bleh"; binmode G; while(<F>) { print G; } '
adam@2cb:~$ ls -la nofx\ -\ falling\ in\ love.mp3 bleh
-rw-r--r-- 1 adam users 5011330 Sep 20 13:00 bleh
-rw-r--r-- 1 adam users 5011330 Jan 24 2002 nofx\ -\ falli
+ng\ in\ love.mp3
adam@2cb:~$ cksum nofx\ -\ falling\ in\ love.mp3 bleh
2095826934 5011330 nofx - falling in love.mp3
2095826934 5011330 bleh
The original/new files end up exactly the same - perl is handling the binary data just fine.
update: added binmode G;. example was only working without it because i'm a linux weenie? |