#!/usr/bin/perl use strict; use warnings; open(SERIALS, "serials.txt") or die("can't open serials.txt"); my @serials = ; for my $serial (@serials) { chomp $serial; print "now processing $serial"; system("echo grep $serial logs* > $serial.log"); }