#!/usr/bin/perl use strict; use warnings; use File::Find; use Cwd; my @SetBCs; open(my $file, "<", "Files.txt") or die "Failed to open file: $!\n"; while(<$file>) { chomp; push @SetBCs, $_; } close $file; foreach (@SetBCs) { my $command = qx(sed -n "/Sets/,/Rules/p" $_); print $command; }