in reply to Extract information from several files in directory

In before everyone else suggests using a module for this. Path::Tiny is my current favorite module for general file bashing.

#!/usr/bin/perl use strict; # 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


:::::::::::::: Filer/one.txt :::::::::::::: one two three four five six :::::::::::::: Filer/three.txt :::::::::::::: thirteen fourteen fifteen sixteen seventeen eighteen :::::::::::::: Filer/two.txt :::::::::::::: even eight nine ten eleven twelve :::::::::::::: output.second.column :::::::::::::: two five fourteen seventeen eight eleven

Is this the kind of thing you were looking for ?

P.S. See, it really is simple...