Yes and no. Format depends on fixed width fonts (ie Courier New and friends) to line up the stuff. Here is a table in fixed width font

fixed | width | format ------+-------+------- foo | bar | baz

And here is the same thing in variable width font (completely naff):

fixed | width | format
------+-------+-------
foo | bar | baz

If you can tolerate that you would just stick the output of format into a scalar and then insert it with a fixed width font type into Word and it will all look fine. format is a legacy item and painful to use. To capture its output you need a filehandle. I would just use sprintf which can do anything format can.

my $tmpfile = 'c:/tmp/tmp.txt'; $str = 'widget'; $cost = 10; format Something = Item: @<<<<<<<<@>>>>> $str, '$' . sprintf("%.2f",$cost) . # format is a pain in the ass and won't write to an IO::Handle so we # need to go through these contortions open TMP, "+>$tmpfile" or die $!; select(TMP); # need to select our file as the output handle for w +rite $~ = 'Something'; # now select our format write TMP; # now write it seek TMP, 0, 0; # up to the top of the file to read it select(STDOUT); # reinstate STDOUT as our ouput handle @data = <TMP>; # read in our formatted data close TMP; # clean up unlink $tmpfile; print @data; # wohoo

To 'format' variable width fonts you need tables or perhaps columns at a pinch. Either use Word ones or Excel. Making a formatted table in Excel and then inserting this as an object into Word is much better documented than manipulating tables in Word so will be easier to do.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Re: Re: Changing the STDOUT Font for word by tachyon
in thread Changing the STDOUT Font for word by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.