my @in = grep { /\.txt$/ } readdir IN; # read all file names form dir +except names started with dot
Your code does not exclude file names that start with a dot (hidden files). To do that you need this:
my @in = grep { !/^\./ && /\.txt$/ } readdir IN; # read all file names + from dir except names started with dot
open IN, '<', "Outpatient/$in" || next; open OUT, '>', "TXT/$in" || die "can't open file Formatted/$in";
Your opens will not fail correctly because of the high precedence of the || operator.
You need to either use the or operator (low precedence):
open IN, '<', "Outpatient/$in" or next; open OUT, '>', "TXT/$in" or die "can't open file Formatted/$in";
Or use parentheses:
open( IN, '<', "Outpatient/$in" ) || next; open( OUT, '>', "TXT/$in" ) || die "can't open file Formatted/$in";
In reply to Re: Issue with Loop when Apostrophe in Field
by jwkrahn
in thread Issue with Loop when Apostrophe in Field
by jalopez453
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |