#!/usr/bin/perl print "*** DO NOT TRUST OUTPUT WITHOUT CHECKING IT FOR SANITY ***\n\n\n"; print "Enter the name of the files you wish to convert: "; chop ($infile = ); print "\n"; print "Enter the name of the file you wish to output: "; chop ($outfile = ); open(IN, $infile) || die "Sorry, can't open $infile. Check the name and try this again."; open(OUT, ">$outfile") || die "Sorry, can't write $outfile"; print OUT "Fund\tTitle\tVendor\tInvoice Number\tInvoice Date\tPaid Date\tCost\n"; while ($line = ) { $_ = $line; @line= split(/\^/, $line); # This next line assigns each item output from the file to a variable. # An array begins with element 0, which should be the fundcode if that was the # first item you chose to output as instructed above. If you wish to remove or # add new items, make sure you recognize the order in which the item was added to # your file (for example, if you chose to add the Status code after the title, # status would become element 2, and you would assign it to a variable by doing # something like this: "$status = $line[2]" Of course, then $vendor would become # 3 and so on. YOu may also delete items here if you do not wish to export $code 2 # or $ordtype. $fund = $line[0]; $title = $line[1]; $vendor = $line[2]; $paid = $line[3]; chomp ($url); # Whichever field comes last needs to be chomped, or could chomp $line right after reading it from input file if ($paid =~ /.*~.*/) { @multipaid = split (/~/, $paid); foreach $paid (@multipaid) { &break_out_paid; } } else { &break_out_paid; } } close (OUT); close (IN); sub break_out_paid { @paid = split (/ /, $paid); $length = scalar(@paid); $ino = $paid[2]; $idate = $paid[1]; $pdate = $paid[0]; for ($i=3; $i <= $length;$i++) { if ($paid[$i] =~ /\$.*/) { $cost=$paid[$i]; $cost =~ s/\$//; $cost =~ s/\,//; } } print OUT "$fund\t$title\t$vendor\t$ino\t$idate\t$pdate\t$cost\n"; $cost = undef; $idate = undef; $ino = undef; }