foreach (@files) { open FILE, "$_" or die $!; print "$_", br() x3; $_ = map m{([^/]+)\.txt}, $_; #Strip out of the string the path and extension leaving only the filename intact print "$_", br() x3; $data = ; #Grab the whole file contents at once print "$data"; exit; close FILE; }