#!/usr/bin/env perl use strict; use warnings; use Path::Tiny; use Capture::Tiny ':all'; my @paths = path('./')->children( qr/\.fa$/ ); foreach my $file_path (@paths){ my $query_file = $file_path->stringify; my $output_file = path( $file_path->parent, $file_path->basename( '.fa' ).'_output.txt' )->stringify; my $cmd = "tblastn -query $query_file -db genome.db". " -out $output_file"; print "Query file: $file_path\n"; print "\t $cmd\n"; my ($stdout, $stderr, $exit) = capture { system( $cmd ); }; if ($exit != 0){ die "Error: command failed"; } } exit;