in reply to insert filename into multiple tab delimited files

If your file is simply tab-delimited, you can add the file column without using any external modules, simply adding tab and filename at the end of each line :) Like this:
{ local @ARGV = @FILES; local $^I = '.orig'; my %seen; while (<>) { (s/$/\tFilename/, (print), next) unless $seen{$ARGV}++; s/$/\t$ARGV/; print; } }
This fragment of code also saves all original files with '.orig' extension.

Replies are listed 'Best First'.
Re^2: insert filename into multiple tab delimited files
by eagleroy (Initiate) on Jul 05, 2006 at 22:47 UTC
    Thanks, I will give it a try
Re^2: insert filename into multiple tab delimited files
by eagleroy (Initiate) on Jul 06, 2006 at 13:29 UTC
    I tried this and I got rows(no new column) interspersed within the data. And the rows had unreadable characters.