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

Hello again,

i asked for the usage of formats and variables. for this topic i got a solution (thx jmcnamara). This was discussed at http://www.perlmonks.org/index.pl?node_id=6364&user=ppm or direct How to route a format into a variable.

But now i have a new problem:

>> (jmcnamara) I wasn't fully sure what you wanted to do with the ~~:

I will format the Information at "Art.nr." and "Bezeichnung" for multiline output ... In the normal format i will do this with ~~ :

format INHALT = @<<<< ^<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>>>>> @>>>>>>>>> $menge,$nr,$text,$preis,$summe, ~~ ^<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<< $nr, $text .
But this doesn't work with the formline example .. there are any solutions?

thx again! ppm

update (broquaint): changed absolute links to a shortcut and a relative link

Replies are listed 'Best First'.
Re: Once more, question about Formats
by jmcnamara (Monsignor) on Feb 14, 2003 at 10:22 UTC

    I posted an updated solution to this here Re: How to route a format into a variable.

    The reason that ~~ doesn't really work with formline() is explained in perlfunc:

    formline PICTURE,LIST ... Note that a format typically does one `formline' per line of form, but the `formline' function itself doesn't care how many newlines are embedded in the PICTURE. This means that the `~' and `~~' tokens will treat the entire PICTURE as a single line. You may therefore need to use multiple formlines to implement a single record format, just like the format compiler. ...

    --
    John.

      Hey jmcnamara,

      youre the best ;o) thx a lot! i've learned much about formats in perl. i never looked at this topic before but now i need to use it.

      Btw .. do you know a better way to make a output like this in my e.g.? or is the usage of formats allready up to dat?

      beste regardes

      ppm

        I think in your case you should be fine with formats. However, if you have something more complex or would like to split up code and layout, then a templating system might be a good solution, see e.g. a discussion on Text::Template here at PM, with pointers to other templating modules.

        -- Hofmator

Re: Once more, question about Formats
by Hofmator (Curate) on Feb 14, 2003 at 13:39 UTC
    A sidenode: If you want to point to something else in the Monastery, then don't use <a href=...></a>. The problem with that is that some of us access PM through www.perlmonks.com and some through www.perlmonks.org. With a direct link, you loose your logged-in status if you go from com to org - or the other way round.

    Instead use the internal format for linking with [234758|your node] which looks like this: your node. For more explanation on that syntax look here.

    -- Hofmator

      Hofmator, thx for your information .. i know text::template .. i use for complexe templates html::template. my links will be set in the future like your e.g. ;o)