Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Is it possible to make an table from plain text ?
So that i don't have to make HTML emails.
Is this possible with perl ?

Replies are listed 'Best First'.
Re: plain text table
by davorg (Chancellor) on Jul 11, 2000 at 12:36 UTC

    In the good old days when everyone read emails using a text-based client, then you could rely on a fixed width font and you'd just insert the appropriate number of spaces. These days, however, people insist on variable width fonts which break these kinds of layouts.

    Can you not attach a text file containing the table? Or use (*spit*) HTML mail and put the table within <pre> tags?

    --
    <http://www.dave.org.uk>

    European Perl Conference - Sept 22/24 2000, ICA, London
    <http://www.yapc.org/Europe/>
Re: plain text table
by jjhorner (Hermit) on Jul 11, 2000 at 17:53 UTC

    Didn't merlyn write an article for TPJ discussing the use of formats to make data look the way you want it to look?

    Look into formats. They may be old, but they are still handy.

    Learning Perl has a good example of it:

    #!/usr/bin/perl -w while (my $filename = <*.secret>) { open(WORDSLIST, $filename); if (-M WORDSLIST < 7) { while (my $name = <WORDSLIST>) { chop($name); my $word = <WORDSLIST>; chop($word); write; # invoke format STDOUT to STDOUT } } } format STDOUT = @<<<<<<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< $filename, $name, $word . format STDOUT_TOP = Page @<< $% Filename Name Word ================ =========== =========== .

    I hope this helps.

    J. J. Horner
    Linux, Perl, Apache, Stronghold, Unix
    jhorner@knoxlug.org http://www.knoxlug.org/
    
      I didn't do an article for TPJ, but one of my early WebTechniques columns talked about having tabular data spit out as a table for table browsers and text for text browsers. I later rejected the error of my ways though, so I don't recommend that information any more.

      -- Randal L. Schwartz, Perl hacker

(crazyinsomniac) Re: plain text table
by crazyinsomniac (Prior) on Jul 11, 2000 at 11:53 UTC
    Yes it is. ________________________________________________ \ +------------------------+ / \ | TABLE HEADING | / \ .------------------------. / \ | TABLE CONTENT | / \ | | / \ | | / \ +------------------------+ / ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ______________________________________________ |_____¸.·ooO--(> cRaZy is co01. <)--Ooo·.¸_____| ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ