in reply to Re: reading files to different output files.
in thread reading files to different output files.
Okay, tried it again but it writes the names of the comman line input to the output files instead of the content of the input files. :/ Here's my code:
my @fh; my @file_names = ("output1.txt", "output2.txt", "output3.txt"); my @in = <>; my $i = 0; open (READ, @in) || die "cannot open @in: $!.\n"; while ( <> ){ for (my $i=0; $i<=$#file_names; $i++){ $fh[$i]= IO::File->new( ">$file_names[$i]" ) || die "Cannot op +en $file_names[$i]: $!.\n"; print {$fh[$i]} "$_"; } } close (READ); print "done.\n";
by now it feels like I'm mentally retarded :(
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: reading files to different output files.
by Corion (Patriarch) on May 30, 2017 at 11:08 UTC | |
by ic23oluk (Sexton) on May 31, 2017 at 14:25 UTC | |
by choroba (Cardinal) on May 31, 2017 at 14:53 UTC | |
by shmem (Chancellor) on May 31, 2017 at 15:40 UTC | |
by ic23oluk (Sexton) on May 31, 2017 at 15:18 UTC | |
|
Re^2: reading files to different output files.
by shmem (Chancellor) on May 30, 2017 at 11:46 UTC | |
|
Re^3: reading files to different output files.
by Anonymous Monk on May 30, 2017 at 11:10 UTC | |
|
Re^3: reading files to different output files.
by Anonymous Monk on May 30, 2017 at 10:50 UTC |