open INPUT, "<:encoding($enc)", "$dir0/$file" or die "File $file not found!"; open OUTPUT, ">:encoding($enc)", "$dir0/first100_$file" or die "File $file not found!"; while () { my $row_str2 = substr($_,0,500); print OUTPUT $row_str2; }