tosub process_files { my ($function, $parm, $message, $extension, @list) = @_; ...
The loop in process_files would change to besub process_files { my ( $SubArgs ) = @_; my $function = $SubArgs->{ function } my $message = $SubArgs->{ message } my $parm = $SubArgs->{ parm } || ""; # If no parameter, def +ault to "". my $extension = $SubArgs->{ extension }; my @list = @{ $SubArgs->{ list } }; ...
Another note: I don't believe the double quotes are needed where you build your argument list.foreach my $file (@list) { my $Newfile = substr($file, 0, 2); $Newfile = $Newfile . $extension; print "($function) $message $file to $Newfile\n"; @args = ("$function", "$parm", "$Newfile", "$file"); system(@args) == 0 or die "system @args failed: $?"; push @returnlist, $Newfile; }
So now your calls look like this:
It might also be possible just to dump the parameter variable and use "mpg123 -qw" as the function you're running. It means your status message gets a little munged, but that makes the code a little simpler.# rename files to 01.mp3, 02.mp3, etc. my @mp3list = process_files( { function => "mv", message => "renaming", extension + => "\.mp3", list => @list } ); # call mpg123 to convert .mp3 to .wav my @wavlist = process_files( { function => "mpg123", param => "-qw", message => " +converting", extension => "\.wav", list => @mp3list } ); # call sox to convert each .wav to .cdr my @cdrlist = process_files( { function => "sox", message => "converting", extens +ion => "\.cdr", list => @wavlist } );
--t. alex
"Of course, you realize that this means war." -- Bugs Bunny.
In reply to Re: From MySQL MP3 Database to CD-R
by talexb
in thread From MySQL MP3 Database to CD-R
by shockme
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |