in reply to Video information

That's not really a module ... first, even if you do consider that a module, it really is two modules. Second, modules are not meant to be executed, so no need for the 'she-bang' line. Third, if you are going to make a module, i really recommend you stick with the Object Oriented paradigm, but that's just me. Here is a shell that uses OO as well as allows the client to chose whether to use mpgtx or ffmpeg. (This is untested.)

package Info::Video; use strict; use warnings; my %value_types = ( mpginfo => '/usr/bin/mpgtx -i', ffmpeg => '/usr/bin/ffmpeg', ); sub new { my $class = shift; my $type = shift || 'mpginfo'; die "invalid type:$type\n" unless $valid_type{$type}; my $self = { type => $type, duration => '00:00:00.0', bitrate => 0, vcodec => '', vformat => '', framerate => '0.00', acodec => '', samplerate => 0, stereo => 0, audiorate => 0, }; return bless $self, $class; } sub video_info { my $self = shift; my $file = shift; # note: use $valid_types{ $self->{type} } for executable if ($self->{type} eq 'mpginfo') { # handle mpginfo } elsif ($self->{type} eq 'ffmpg') { # handle ffmpg } return $self; } 1;
And a simple client:
#!/usr/bin/perl use strict; use warnings; use Info::Video; my $info = Info::Video->new('ffmpeg'); $info->video_info(); # now $info contains the video information

That's a decent "first stab" at the problem. It is far from optimal, but it should illustrate a better way of getting things done. I don't like having to use an if-elsif inside the video_info() sub ... i would consider using a Factory Pattern instead (or Class::Factory). I would also consider using Class::MethodMaker so that you can automatically add accessor methods to your object, instead of mucking directly with the attributes. Finally ... use POD! Don't use simple # comments for documentation, save those for simple comments.

And finally finally, don't stick use warnings; in the middle of a for loop. Cheers! :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)