#!/usr/bin/perl
# --------------------------------------
# Process data file, and convert to
# CSV quote delimited format
# --------------------------------------
use Text::ParseWords ;
while (<STDIN>) {
$line1 = $_ ;
chomp $line1 ;
$line1 =~ s/\\/0/;
$line1 =~ s/X/Z/;
#print $line1 , "\n" ;
@flist = parse_it ($line1) ;
for ($i=0;$i<@flist;$i++)
{
if ( $i > 0 )
{
$line2 = $line2 . "|";
}
else
{
$line2 = "";
}
$line2 = $line2 . $flist[$i];
}
print $line2 , "\n" ;
}
sub parse_it {
return quotewords(",", 0, @_ );
}
|
|