C
ccc31807
See the script and output below. The problem is that DATA contains a
single quote in the name O'Toole. Is there any way to get this to
work? Or do I have to roll my own?
Or (horrors) do I have to munge DATA to escape every single quote?
Thanks, CC.
---------------------script---------------------
use strict;
use warnings;
use Text:arseWords;
while (<DATA>)
{
chomp;
#my ($id, $first, $last, $csz) = split /,/;
my ($id, $first, $last, $csz) = parse_line(',', 0, $_);
#my ($id, $first, $last, $csz) = quotewords(',', 0, $_);
###my ($id, $first, $last, $csz) = shellwords(',', 1, $_); never works
###my ($id, $first, $last, $csz) = nested_quotewords(',', 1, $_);
never works
print "$id, $first, $last, $csz\n";
}
exit(0);
__DATA__
1234,John,Smith,"New York, NY"
2345,Karl,Tomas,"Boston, MA"
98765,Sean,O'Toole,"Dublin, Ireland"
34567,Lewis,Uberville,"Nashville, TN"
---------------output---------------------------------
D:\PerlLearn\ParseWords>perl test_1.plx
1234, John, Smith, New York, NY
2345, Karl, Tomas, Boston, MA
Use of uninitialized value in concatenation (.) or string at
test_1.plx line 13,
<DATA> line 3.
Use of uninitialized value in concatenation (.) or string at
test_1.plx line 13,
<DATA> line 3.
Use of uninitialized value in concatenation (.) or string at
test_1.plx line 13,
<DATA> line 3.
Use of uninitialized value in concatenation (.) or string at
test_1.plx line 13,
<DATA> line 3.
, , ,
34567, Lewis, Uberville, Nashville, TN
single quote in the name O'Toole. Is there any way to get this to
work? Or do I have to roll my own?
Or (horrors) do I have to munge DATA to escape every single quote?
Thanks, CC.
---------------------script---------------------
use strict;
use warnings;
use Text:arseWords;
while (<DATA>)
{
chomp;
#my ($id, $first, $last, $csz) = split /,/;
my ($id, $first, $last, $csz) = parse_line(',', 0, $_);
#my ($id, $first, $last, $csz) = quotewords(',', 0, $_);
###my ($id, $first, $last, $csz) = shellwords(',', 1, $_); never works
###my ($id, $first, $last, $csz) = nested_quotewords(',', 1, $_);
never works
print "$id, $first, $last, $csz\n";
}
exit(0);
__DATA__
1234,John,Smith,"New York, NY"
2345,Karl,Tomas,"Boston, MA"
98765,Sean,O'Toole,"Dublin, Ireland"
34567,Lewis,Uberville,"Nashville, TN"
---------------output---------------------------------
D:\PerlLearn\ParseWords>perl test_1.plx
1234, John, Smith, New York, NY
2345, Karl, Tomas, Boston, MA
Use of uninitialized value in concatenation (.) or string at
test_1.plx line 13,
<DATA> line 3.
Use of uninitialized value in concatenation (.) or string at
test_1.plx line 13,
<DATA> line 3.
Use of uninitialized value in concatenation (.) or string at
test_1.plx line 13,
<DATA> line 3.
Use of uninitialized value in concatenation (.) or string at
test_1.plx line 13,
<DATA> line 3.
, , ,
34567, Lewis, Uberville, Nashville, TN