Home > Archive > PERL Beginners > November 2005 > formatting text
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Ing. Branislav Gerzo 2005-11-29, 6:57 pm |
| Hello all,
I'd like to know if there is module for following:
We have text:
=== IN ===
This is just small sentence about nothing.
=== IN ===
And I like to format it as follows:
11111111112
12345678901234567890
=== OUT ===
| This is just |
| small sentence |
| about nothing. |
=== OUT ===
So, I'd like to define "|" as start and as end, word-wrapped text,
and length of line is lets say "20" chars.
I looked into Text::Format module, but it has different functions...
If there is a such a module, it is ok, if not, I will write something
myself, but don't like to reinventing wheel.
Thanks a lot.
/brano
| |
| Jeff 'japhy' Pinyan 2005-11-29, 6:57 pm |
| On Nov 29, Ing. Branislav Gerzo said:
> I'd like to know if there is module for following:
Yes, Perl6::Form. It's a Perl 5 implementation of Perl 6's formats.
> 11111111112
> 12345678901234567890
> === OUT ===
> | This is just |
> | small sentence |
> | about nothing. |
> === OUT ===
>
> So, I'd like to define "|" as start and as end, word-wrapped text,
> and length of line is lets say "20" chars.
You could use Perl 5's formats, but they're ugly to work with.
Perl6::Form presents them in a simpler and better fashion.
use Perl6::Form;
print form
"| {[[[[[[[[[[[[[[[[} |",
$string
;
does what you want. See the module's documentation for details.
You'll have to download the module from CPAN, since I highly doubt you
already have it.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://www.perlmonks.org/ % have long ago been overpaid?
http://princeton.pm.org/ % -- Meister Eckhart
| |
| Ing. Branislav Gerzo 2005-11-29, 6:57 pm |
| Jeff 'japhy' Pinyan [JP], on Tuesday, November 29, 2005 at 09:12
(-0500 (EST)) thoughtfully wrote the following:
[color=darkred]
JP> Yes, Perl6::Form. It's a Perl 5 implementation of Perl 6's formats.
sometime is better ask, than DIY. Thanks a lot Japhy, this is exactly
what I'm looking for!
Thanks, thanks and again: thanks.
--
How do you protect mail on web? I use http://www.2pu.net
[Windows: At least the disks make nice drink coasters]
| |
| Ing. Branislav Gerzo 2005-11-29, 6:57 pm |
| Jeff 'japhy' Pinyan [JP], on Tuesday, November 29, 2005 at 09:12
(-0500 (EST)) wrote the following:
Jeff, Perl6::Form is so powerful. But I can't find how to properly do
this:
I have values:
('Name','Branislav');
('Surname','Gerzo');
And I'd like to print:
| Name............: Branislav |
| Surname.........: Gerzo |
26.^ 80.^
Could you please help me with this one ? Other I need I already got,
but this one seems tricky for me.
Thanks.
--
How do you protect mail on web? I use http://www.2pu.net
[I wanna get my kicks now before I go.]
| |
| Brano Gerzo 2005-11-29, 6:57 pm |
| Ing. Branislav Gerzo [IBG], on Tuesday, November 29, 2005 at 17:14
(+0100) wrote:
IBG> And I'd like to print:
IBG> | Name............: Branislav |
IBG> | Surname.........: Gerzo |
IBG> 26.^ 80.^
Nothing is tricky, if man want. So:
sub formie {
print form
'| {<<<<<<<<<<<<<<}: {[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
[[[[[[[[} |',
{rfill=>'.'}, shift, {rfill=>' '}, shift;
}
--
...m8s, cu l8r, Brano.
[Don't bother with the shrimp baby, daddy's comin' home with the crabs!]
|
|
|
|
|