I need to delete the first 9 lines of every file in a directory. I know that the list of files has "." in $files[0] and ".." in $files[1], so I started with a $files[2] as the first file, but I did not delete any lines from the files.
Here is the code I used,
opendir(DIR, "D:\\EDI_Inv");
@files = readdir(DIR);
closedir(DIR);
# this deletes the first 9 lines of each file
for ($i = 2; $i < @files; $i++)
{
$name = @files[$i];
open(FH,$name);
@array = <FH>;
close FH;
open(OUT,">$name");
print OUT @array[9..$#array];
close OUT;
}
This reads the list of files just fine, but it does not delete the first 9 lines.
Does anybody have any ideas of what I did wrong?
Here is the code I used,
opendir(DIR, "D:\\EDI_Inv");
@files = readdir(DIR);
closedir(DIR);
# this deletes the first 9 lines of each file
for ($i = 2; $i < @files; $i++)
{
$name = @files[$i];
open(FH,$name);
@array = <FH>;
close FH;
open(OUT,">$name");
print OUT @array[9..$#array];
close OUT;
}
This reads the list of files just fine, but it does not delete the first 9 lines.
Does anybody have any ideas of what I did wrong?