J
julia
Hello,
I am trying to write a script that read files in a directory that I
can supply at the command line. (split.pl in). The script aborted...
Please help me find how to fix the problem.
Thanks
use strict;
my $input_dir = $ARGV[0] || '.' ;
MAIN:
opendir DIR, $dir || die "Couldnt open $dir - $!\n";
my @entries = readdir(DIR);
closedir (DIR);
foreach my $file (@entries) {
my $filename = "$dir/$file";
if ( -f $filename ){
open(F, "<$filename");
}
}
while (<F>) {
my @words = split(/\W*\s+\W*/, $_); # split
foreach my $num ( 0 .. $#words) {
open OUT, ">out_$filename.txt" and select OUT if 1..1;
{print $num+1, "\t$words[$num] -- file $filename\n"}
}
}
I am trying to write a script that read files in a directory that I
can supply at the command line. (split.pl in). The script aborted...
Please help me find how to fix the problem.
Thanks
use strict;
my $input_dir = $ARGV[0] || '.' ;
MAIN:
opendir DIR, $dir || die "Couldnt open $dir - $!\n";
my @entries = readdir(DIR);
closedir (DIR);
foreach my $file (@entries) {
my $filename = "$dir/$file";
if ( -f $filename ){
open(F, "<$filename");
}
}
while (<F>) {
my @words = split(/\W*\s+\W*/, $_); # split
foreach my $num ( 0 .. $#words) {
open OUT, ">out_$filename.txt" and select OUT if 1..1;
{print $num+1, "\t$words[$num] -- file $filename\n"}
}
}