in reply to Re^2: Copying a hash to an array of hashes.
in thread Copying a hash to an array of hashes.

The issue you are encountering is that the first element of @gl_thread_queue_arr is still a reference to the same object you are now modifying. If you want to create a new ffmpeg job, you need to create a new ffmpeg object to reference it. Something like this (built off the FFmpeg::Command example, untested):

use FFmpeg::Command; my @gl_thread_queue_arr = (); while (<DATA>) { my @options = split; my $ffmpeg = FFmpeg::Command->new('/usr/local/bin/ffmpeg'); $ffmpeg->input_options({ file => $options[0], }); # Set timeout $ffmpeg->timeout(300); # Convert a video file into iPod playable format. $ffmpeg->output_options({ file => $options[1], device => 'ipod', }); push @gl_thread_queue_arr, $ffmpeg; # Add job to Ffmpeg queue } foreach my $ffmpeg (@gl_thread_queue_arr) { my $result = $ffmpeg->exec(); croak $ffmpeg->errstr unless $result; } __DATA__ input_file1 output_file1 input_file2 output_file3 input_file3 output_file2

Replies are listed 'Best First'.
Re^4: Copying a hash to an array of hashes.
by Steve_BZ (Chaplain) on Sep 22, 2009 at 02:02 UTC

    Hi Kenneth

    Thanks for all the trouble you went to. You are quite right, I needed to have mutliple "new"s.

    It's all more or less in working order now and I'm unit testing for the normal problems. Thanks again

    Regards