use IPC::Run3; foreach my $file (@files) { my $savefile = $file; $cmd = [ (qw(p4 where), $file) ]; run3($cmd, \$stdin, \$stdout, \$stderr); if ($stderr =~ /file\(s\) not in client view/) { push @branched_paths,"$savefile"; } }