#!/usr/bin/perl use strict; use warnings; my $folder = $ARGV[0]; my $output = 'C:\Users\AndreyT\Desktop\tee.txt'; foreach(glob "$folder\*.nfo"){ use_contents($_); } sub use_contents{ my $filename = shift; open my $fh, '<$filename' or die "Can't open $filename: $!"; open my $dat1, '>$output' or die "\nERROR: Cannot create/open $output\n"; while(<$fh>){ print $dat1 $_;} close ($fh); close ($dat1); }