our $template; &template_fun; $template =~ s/\#([^\#])\#/${$1}/ge; # see update note my $tmstamp = localtime; $tmstamp =~s/ |:|-/_/g; my $tmpfile = "D:\\pdfs\\" . $tmstamp . ".html"; open (HTMLFILE, ">$tmpfile") || die "cannot do it: $!"; print HTMLFILE "$template"; close(HTMLFILE); ## here's where we make the actual system call chdir "D:\\HTMLDOC\\"; system("htmldoc -t pdf --webpage -f D:\\pdfs\\" . $RGA_num . ".pdf $tmpfile"); unlink $tmpfile; sub template_fun(){ $template = '
Returned Goods Authorization


#companyName#
#ourphone# #ourfax#

 
To: #attn#
Company: #cust_name#
Phone: #phone#
#dmethod#: #fax#
From: #tech#
Fax back: #our_fax#
Reason for return: #code#
Date: #date#
Order number: #ord_num#

RGA number: #RGA_num# (Write this number on the outside of your package) #raddress#

'; }