#!/usr/bin/perl
$comma=",";
open (SOURCE, "NEWCAT01.") || die "Cannot open: $!";
open (DESTINATION1, ">>NEWCAT01-ECON.csv") || die "Cannot open: $!";
open (DESTINATION2, ">>NEWCAT01-DEMO.csv") || die "Cannot open: $!";
sub prep {
$string=$_[0]; #Best practice: my ($string, $dest, $term)=@_;
$dest=$_[1]; #for unpacking the argument array.
$term=$_[2];
chomp $string;
$string=~ s/^\s+//; #Remove leading white space
$string=~ s/\s+$//; #Remove trailing white space
if ($string eq ""){ #If the string is empty insert a ? into the field
$string="?";
}
print $dest $string; #Output the string
if ($term==0){ #If the value does not terminate the line output a comma.
print $dest $comma;
}
else{ #If the value does terminate the line output an end of line.
print $dest "\n";
}
}
$count=1;
while(