#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11124289 use warnings; use Path::Tiny; my $dirname = 'Filer'; my $outputfile = path('output.second.column'); $outputfile->spew(''); # empty file for my $file ( path($dirname)->children( qr/\.txt\z/ ) ) { $outputfile->append( map { (split /\t|\n/)[1] . "\n"} $file->lines ); } # following for debug only :) system 'more Filer/* output.second.column | cat'; # because 'more' shows filename and contents when piped