adding a filename into a data file

Tony Edwardson Tony.Edwardson at
Mon Nov 5 06:37:16 PST 2012

or just
while  (<>) {
            print "$ARGV $_";

-----Original Message-----
From: MiltonKeynes-pm [ at] On Behalf Of Benjamin Martin
Sent: 05 November 2012 14:33
To: miltonkeynes-pm at
Subject: Re: adding a filename into a data file

On 05/11/12 14:13, Matt Croft wrote:
> Is this possible in perl?

Something like this:

#!/usr/bin/env perl

use strict;
use warnings;
use autodie;

my $base_dir = "/home/person";   # as base dir to read/write file to/from
my @files = qw/file1.txt file2.txt/;  # the files to read and combine

open $new_fh, ">", "$base_dir/NEWFILE.txt"; # open the master file to
receive all files content
foreach my $f (@files) {

   my $fh
   open $fh, "<", "$base_dir/$f";
   while(<$fh>) {
     print $new_fh "$f $_";
   close $fh;

close $fh2;

This email, its content and any files transmitted with it are intended solely for the addressee(s) and may be legally privileged and/or confidential. If you are not the intended recipient, you may not divulge any of its contents to anyone and should delete the email and contact the sender on the telephone number shown above or via return email. Messages sent via this medium may be subject to delays, non-delivery and unauthorised alteration.  This email has been prepared using information believed by the author to be reliable and accurate, but neither TwentyCi Limited, nor any of its subsidiaries or associates makes any warranty as to its accuracy or completeness.  Any opinions or recommendations expressed herein are solely those of the author. TwentyCi Limited is a company registered in England, No.06943607. The registered office address is: 6 Whittle Court Knowlhill Milton Keynes MK5 8FT
MiltonKeynes-pm mailing list
MiltonKeynes-pm at

A copy of the LCH.Clearnet e-mail disclaimer can be found at:  

LCH.Clearnet Limited, Registered Office: Aldgate House, 33 Aldgate High Street, London EC3N 1EA. 
Recognised as a Clearing House under the Financial Services & Markets Act 2000. Reg in England No.25932.
LCH.Clearnet SA, Siège Social, 18 rue du Quatre Septembre, 75002 Paris, Chambre de Compensation conformément au Code Monétaire et Financier.

More information about the MiltonKeynes-pm mailing list