#!/usr/bin/perl # Slightly modified by Tom 7/2/02 to include MARC 856 field print "*** EXPERIMENTAL VERSION WITH MARC 856 FIELDS ***\n*** 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\tCode2\tOrderType\tInvoice Number\tInvoice Date\tPaid Date\tCost\t\tURL\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]; $code2 = $line[4]; $ordtype = $line[5]; $url = $line[6]; 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; $tamount += $iamount; } print OUT "$fund \t$title TOTAL \t $vendor \t\t\t\t\t\t$tamount\n"; $tamount = undef; } 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/\,//; $iamount=$cost; } } print OUT "$fund\t$title\t$vendor\t$code2\t$ordtype\t$ino\t$idate\t$pdate\t$cost\t\t$url\t\n"; $cost = undef; $idate = undef; $ino = undef; $ordtype=undef; $code2=undef; }