Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print a perl formatted file

Status
Not open for further replies.

eaperezh

MIS
Jul 9, 2004
9
PA
Hi, I still learning perl so I excuse if this question is lame.

I have several files in my local disk, generated by another application (made by a 3rd party) with the following data:

*******(extract of the file)*************

.\" Definition of the Page Header for the first message
.de PH
.tl '08/10/04-09:04:15' Printer-3081-000001 ' \\n% '
.tl ' _'____________________________________________________________________'_'
..
.wh 0 PH \" Trap at line 0 (top of each page). Print the page header
.nf
.sp
.po +7
.ds a4 '-'--------------------- \fB Instance Type and Transmission\fP --------------'-'
.tl \*(a4
.ta 24
Copy \
received from DATUM
Message Output Reference : 0903
93172132312123
Correspondent Input Reference : 0501 04100812345XXGXXX0000275256
.ds a4 '-'--------------------------- \fBMessage Header\fP -------------------------'-'
.tl \*(a4
.ta 13
DATUM Output : \

******(end of file extract)********

Question:
These are perl formatting codes right?
How can I "print" these kind of files to a local printer so perl outputs "clean" information?
 
There's no such thing a perl formatted file to my knowledge

That is formatting, but it's most likely required by the 3rd party app to which you referred.

You could use substitutions to remove 'unsightly' formatting
Code:
$string=".\" Definition of the Page Header for the first message
.de PH
.tl '08/10/04-09:04:15'            Printer-3081-000001 ' \\n% '
.tl '    _'____________________________________________________________________'_'
..
.wh 0 PH    \" Trap at line 0 (top of each page). Print the page header
.nf
.sp
.po +7
.ds a4 '-'--------------------- \fB Instance Type and Transmission\fP --------------'-'
.tl \*(a4
.ta 24
Copy \
received from DATUM
Message Output Reference     : 0903
93172132312123
Correspondent Input Reference     : 0501 04100812345XXGXXX0000275256
.ds a4 '-'--------------------------- \fBMessage Header\fP -------------------------'-'
.tl \*(a4
.ta 13
DATUM Output     : \
 ";
$string=~s/\\(.?)//g;  # it's quite possible this one won't do it all, regexes aren't my strong suit

There's a lot of header information as well which could be useful. My advise would be to research the 3rd party app to determine what the .sp, .nf etc are all for, before discarding anything.

It does look a little postscriptish, but the functions must have been redefined, have a look at the header of the actual file to see if there's any information about the file type

HTH
--Paul

Nancy Griffith - songstress extraordinaire,
and composer of the snipers anthem "From a distance ...
 
I found that this is TROFF formated. Now I have to learn how to print troff formatted files.
 
If you have a printer set up you can do this

troff your_file | lp


Mike

"Deliver me from that bane of civilised life; teddy bear envy."

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

 
This is a windows machine (no access to unix)
I have something called nroff.exe in one of the directories.

can i use that?
 
I would think so yes, try this

nroff your_file > file_to_print.txt
print file_to_print.txt

Mike

"Deliver me from that bane of civilised life; teddy bear envy."

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top