Hello, I have a loop that goes through each text file. It works great, but the problem is when there is an apostrophe in my second field the script errors and does not append the detail. I am not sure what is causing this, but I was wondering if someone would be able to help me identify the issue and possibly fix it.
#!/usr/bin/perl -w use strict; use warnings; use Text::ParseWords; opendir IN, 'Outpatient'; my @in = grep { /\.txt$/ } readdir IN; # read all file names form dir +except names started with dot closedir IN; for my $in (@in) { open IN, '<', "Outpatient/$in" || next; open OUT, '>', "TXT/$in" || die "can't open file Formatted/$in"; while(<IN>) { my @f = quotewords ',', 0, $_; print OUT join "," => @f; } close OUT; close IN; } INPUT FILE: """555522""",MEN'S HEALTH DEPARTMENT,"""12/31""" OUTPUT FILE: **BLANKS EXPECTED OUTPUT: 555522,MEN'S HEALTH DEPARTMENT,12/31
In reply to Issue with Loop when Apostrophe in Field by jalopez453
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |