in reply to How to output file data from files in an array to one singular file?

You have gotten close. I bet you noticed that $outfile only contained a list of the filenames that were janfiles, rather than the contents of those files.

open (my $ofile, '>',$outfile) || die "Unable to open Write File! $out +file\n"; for my $infn (@JanFiles) { open (my $infile,'<',$infn) || die "Unable to open input file! $infi +le \n"; while (my $line=<$infile>) { print $ofile $line;} close ($infile); } close $ofile;

Edit, fixed quotes typo from c&p

  • Comment on Re: How to output file data from files in an array to one singular file?
  • Download Code

Replies are listed 'Best First'.
Re^2: How to output file data from files in an array to one singular file?
by perlnovice1900 (Novice) on Mar 26, 2017 at 00:24 UTC

    Hi Huck,

    If I wanted to output that data to a file called 'secure.2006' how would I go about doing that?

    Also big thanks for helping me out!

      It will output to whatever file is named in my $outfile.

      my $outfile = 'secure.200601'; does set it to what you wanted