$target = "BMP"; $current = "JPEG"; $Config{'Options'}{'Converted File'} = "converted.bmp"; $Config{'Conversions BMP'}{'JPEG'} = 'convert "$infile" "$outfile"'; my $ofile = $Config{'Options'}{'Converted File'}; my $cmd = $Config{"Conversions $target"}{$current}; $cmd =~ s/\$infile/$filename/g; $cmd =~ s/\$outfile/$ofile/g; system $cmd and die "Error converting $filename -> $ofile: $!\n";