in reply to Multi-line Format problem
The relevant passage of perlform is
Inside of an expression, the whitespace characters \n, \t and \f are c +onsidered to be equivalent to a single space. Thus, you could think o +f this filter being applied to each value in the format: $value =~ tr/\n\t\f/ /; The remaining whitespace character, \r, forces the printing of a new l +ine if allowed by the picture line.
You can achieve the output you want by translating the \n's to \r's
#!/bin/env perl -w use strict; my $cookie="Climb the mountains\nand get their good tidings.\nNature's + peace will flow into you\nas sunshine flows into trees.\n"; my $author="-John Muir\n"; $cookie =~ tr[\n][\r]; $: = "- "; format STDOUT = @||||||||||||||||||||||||||||||||||||||||||||||||| "------------------------------------------------" ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $cookie @|||||||||||||||||||||||||||||||||||||||||||| $author @||||||||||||||||||||||||||||||||||||||||||||||||| "------------------------------------------------" . write STDOUT; __END__ ------------------------------------------------ Climb the mountains and get their good tidings. Nature's peace will flow into you as sunshine flows into trees. -John Muir ------------------------------------------------
Though a couple of other adjustments are required.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Multi-line Format problem
by nr0mx (Scribe) on Nov 09, 2003 at 03:08 UTC |