Hi all,
I have been experimenting with formats and was wondering if it's possible to...
a) Define a format
b) Invoke it thru a file handle
then
c) Write the contents of the file handle to a variable rather than the file system
This is as far as I've got when I and everything seems ok
#!/usr/bin/perl
format INVOICE =
+---------------------------------------------------------------------
+--------+
Invoice To Invoice From
+
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<< The Get Rich Quick C
+o.
$name
Address
@*
+
$address
Description: Cost:
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @###.##
$description £$cost
+---------------------------------------------------------------------
+--------+
.
open(INVOICE,">print-invoice");
$name = "Another Sucker";
$address = "Address 1\nAddress2\nXX11 9DJ";
$description = "another mug to help us swell our coffers";
$cost = 999.99;
write (INVOICE);
This works fine apart from the @* denoting a multiline field y/n? gets fed into the output.(any ideas why?) But what I'd like to do is assign it to a variable to use in a template or a 'here document' for instance
I've tried adding stuff like
$invoice =<INVOICE> but this doesn't seem to work
Many thanks
Stew
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.