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