Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

RE: RE (2): pack / unpack woes

by davorg (Chancellor)
on Aug 24, 2000 at 18:05 UTC ( #29419=note: print w/replies, xml ) Need Help??


in reply to RE (2): pack / unpack woes
in thread pack / unpack woes

Something like this perhaps:

my @list = (1, 2, 3); my $tmpl = '%-3s|%-4s|%-5s'; @list = split/\|/, sprintf $tmpl, @list; $" = '='; print "=@list=\n";

...although that won't truncate elements that are too big :(

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

European Perl Conference - Sept 22/24 2000, ICA, London
<http://www.yapc.org/Europe/>

Replies are listed 'Best First'.
RE: RE: RE (2): pack / unpack woes
by merlyn (Sage) on Aug 24, 2000 at 18:37 UTC
    ...although that won't truncate elements that are too big :(
    It will if you use
    my $tmpl = "%-3.3s|%-4.4s|%-5.5s";
    The value after the dot gives a "maximum width".

    -- Randal L. Schwartz, Perl hacker

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://29419]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2022-05-19 16:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (72 votes). Check out past polls.

    Notices?