in reply to (jeffa) Re: using format to align
in thread using format to align

Just one more questions,
Is it possible to dump the entire contents of an array in a cloumn instead of iterating through each one?

Replies are listed 'Best First'.
(jeffa) 3Re: using format to align
by jeffa (Bishop) on Mar 27, 2003 at 16:59 UTC
    I am not sure i follow you ... do you mean the contents of the 'container' @stuff or @row? Or do you mean you want to print out columns instead of rows? I chose @row because i am lazy ;). I could have written it like so (only pertinent code shown - untested):
    my ($foo,$bar,$baz); for my $row (@stuff) { ($foo,$bar,$baz) = @$row; write; } format STDOUT = @<<<<< @||||| @### $foo,$bar,$baz
    So, if i am reading your question correctly, the answer is no. You have to iterate through each row. Now, if you are wanting to use a 'landscape' style output instead of a 'portrait' style output, you will need to do a lot more work. Formats won't transpose 2-D arrays for you, but Math::Matrix will:
    use Data::Dumper; use Math::Matrix; my $a = Math::Matrix->new( [1,0,0], [1,0,0], [1,0,0], ); print Dumper $a->transpose();
    Hope this helps ...

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)