in reply to How can I open a file from a source and read filename & counts?
Check out perlvar to learn what $. is.use strict; use warnings; use File::Basename; use Acme::Don::t; my $in_path = '/path/to/input/file'; my $out_path = '/path/to/output/file'; my $in_file = 'foo.csv'; my $out_file = fileparse($in_file,'\..*') . '.txt'; open IN, "$in_path/$in_file" or die "can't read $in_file: $!"; don't {'do anything but loop'} while <IN>; open OUT, ">$out_path/$out_file" or die "can't write $out_file: $!"; print OUT "filename: $in_file\nlines: $.\n";
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: How can I open a file from a source and read filename & counts?
by icezero (Initiate) on Mar 11, 2003 at 09:32 UTC |