Well I would recommend you do some studying of PURL Formatting.
PURL was written as a word processing script, so easy enough right, WRONG !
You'll need to understand how Formatting works, here is an snippet of a script I wrote for a client who needed values formatted for another off-server program to read.
- Code: Select all
$d="d";
$t="t";
$Version="7.0.0";
if($fileMode eq "live"){
$path = "/u/web/citysa/Orders/"; # Path for the Orders DIR
}
if($fileMode eq "test"){
$path = "/u/web/citysa/StaticCart/cgi-bin/"; # Test Path for the Orders Text File
}
$myfile = qq~$path$b_accountCode$d$mymonth$day$year$t$hour$min$sec.txt~;
use Fcntl; #The Module
sysopen (TEXT, $myfile, O_RDWR|O_EXCL|O_CREAT, 0755);
close (TEXT);
open(MYORDER,">$myfile") or die "Can't open up file: $!\n";
# and this page header format will automatically apply to MYFILE
format MYORDER_TOP =
Company-@<<<<<<<<<<<<<<<<<<< Account#-@<<<<<<<< Version-@<<<<<<<<<<<<<<
$b_company, $b_accountCode, $Version
@<<<<<<<<<<<<<<<<<<<<< Memo Code-@<<< PO#-@<<<<<<<<<<<<<
$filedate, $mc, $b_po
@<<<<<<<<< @>>> @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
"Item #","Qty","Item Description","Sell Unit"
.
format MYORDER =
@<<<<<<<<< @>>> @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
${$ide}, ${$qnt},${$naam}, ${$adlinfo}
.
format MYORDER_BOTTOM =
Item Total = @<<<< Qty Total = @<<<<
$x-1, $WEIGHT
¤http://citysales.com/ @<<<<<<<<<<<<<<<<<<<<<<
$db_update
.
for($y=1;$y<=100;$y++){
$thename="NAME_$y";
if(length(${$thename})>3){
$num5++;
}
}
foreach($x=1; $x<=$num5; $x++){
$qnt="QUANTITY_$x";
$prce="PRICE_$x";
$xtnd="XTEND_$x";
$ide="ID_$x";
$naam="NAME_$x";
$adlinfo="ADDTLINFO_$x";
${$naam}=~ s/\n//g;
write MYORDER;
}
select((select(MYORDER), $~ = "MYORDER_BOTTOM")[0]);
write(MYORDER);
close(MYORDER);
This is placing the words where they are required for another program to read, but it could be used to print out on a pre-printed invoice or statement. Here is the output:
- Code: Select all
Company-Dougs Corner Store Account#-123456 Version-7.0.0
01/15/2008 07:40:51 Memo Code-00 PO#-12875
Item # Qty Item Description Sell Unit
880245 1 CRUSH FRZ ORNGEDREAM BIB 1/5GAL
883025 2 SLUSH PUPPIE BASE BIB CLEAR CHERRY 5/GA 5/GAL
882886 3 THELMAS LEMONADE BIB 2.5GAL 1/EACH
Item Total = 3 Qty Total = 6
¤http://citysales.com/ 2007-10-19 12:08:54