use IPC::Run 'run'; my $file = $ARGV[0] || die; my $line; run [ qw(ffprobe -show_streams),$file ], '&>', \$line || die "$!\n"; my ($width,$height); for (split /\n/,$line) { $width = $1 if /width=(\d+)/; $height = $1 if /height=(\d+)/; # ... $_ eq '[/STREAM]' && defined $width && defined $height && print "${width}x${height}\n" && last }