for my $sql qw(sakila-schema.sql sakila-data.sql) { my $file = "sakila-db/$sql"; my $contents = read_file($file); print "\t$file\n"; open my $fh, '|-', 'mysql', @opt; print $fh $contents; }