T
Tony
I am trying to concatenate all files in a directory together into one
file and read the first 225 characters of each file into one file as
sort of a summary file.
This does cat all file together into one bigfile
my $directory = "c:\\myfiles";
my $bigfile =c:\\bigfile.txt";
opendir (DIR, $directory) or die $!;
@ARGV = readdir(DIR);
chdir( $directory ) or die $!; #Need to do this readdir has just
filename
@ARGV = grep( -f, @ARGV);
foreach (@ARGV) {
local $/ ;
open OUT,">$bigfile" or die $!;
while( <> ){
print OUT $_, "\n";
}
}
close OUT;
closedir(DIR)
Now this does read the first 225 characters from each file but I need
to put it into a single file, not to STDOUT and I can not get the two
to run together in the same script.
chdir( $directory ) or die $!;
@ARGV = grep( -f, @ARGV);
$files = shift(@ARGV);
while (<>) {
open(INFILE,"<$files") or die "Can't open: $!\n";
read(INFILE,$buff,225,0);
print "$buff\n";
}
close(INFILE);
Many thanks for any help..
file and read the first 225 characters of each file into one file as
sort of a summary file.
This does cat all file together into one bigfile
my $directory = "c:\\myfiles";
my $bigfile =c:\\bigfile.txt";
opendir (DIR, $directory) or die $!;
@ARGV = readdir(DIR);
chdir( $directory ) or die $!; #Need to do this readdir has just
filename
@ARGV = grep( -f, @ARGV);
foreach (@ARGV) {
local $/ ;
open OUT,">$bigfile" or die $!;
while( <> ){
print OUT $_, "\n";
}
}
close OUT;
closedir(DIR)
Now this does read the first 225 characters from each file but I need
to put it into a single file, not to STDOUT and I can not get the two
to run together in the same script.
chdir( $directory ) or die $!;
@ARGV = grep( -f, @ARGV);
$files = shift(@ARGV);
while (<>) {
open(INFILE,"<$files") or die "Can't open: $!\n";
read(INFILE,$buff,225,0);
print "$buff\n";
}
close(INFILE);
Many thanks for any help..