http://qs321.pair.com?node_id=668523

Win has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: printing out tabs between each element in an array
by marto (Cardinal) on Feb 18, 2008 at 13:33 UTC
Re: printing out tabs between each element in an array
by haoess (Curate) on Feb 18, 2008 at 13:29 UTC
    I would like to print out a tab character between each element in the array

    There is a builtin special variable $":

    local $" = "\t"; my @a = qw(1 2 3); print "@a"; __END__ 1 2 3

    -- Frank

Re: printing out tabs between each element in an array
by Skeeve (Parson) on Feb 18, 2008 at 13:09 UTC
    You might want to look at the join command join "\t",@cols_for_row;

    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
Re: printing out tabs between each element in an array
by McDarren (Abbot) on Feb 18, 2008 at 13:11 UTC
    Indeed there is. You can use \t to represent a tab. So probably what you want is something like (untested):
    print ARRAY_CONTENTS join("\t", @cols_for_row), "\n";
    Update: added newline

    Cheers,
    Darren

Re: printing out tabs between each element in an array
by olus (Curate) on Feb 18, 2008 at 13:33 UTC

    You can set the output field separator to the tab character.

    $" = "\t"; print ARRAY_CONTENTS "@cols_for_row\n";

    Remember to restore the output field separator to its default value after you're done with the tab formating

      Remember to restore the output field separator to its default value after you're done with the tab formating

      One way to make it difficult to forget is to keep the localisation within the print statement by using a do block.

      print ARRAY_CONTENTS do { local $" = "\t"; "@cols_for_row\n"; };

      I hope this is of interest.

      Cheers,

      JohnGG

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: printing out tabs between each element in an array
by Anonymous Monk on Feb 19, 2008 at 00:57 UTC

    Win,

    I'd just like to offer my sincere congratulations on achieving 9 xp. That's almost 0.02 xp for every one of your 489 posts. We're all crossing our fingers on you making the 10 xp milestone.

    Best of luck!

    - A gutless coward

      Wow.... I was going to create a user profile; I've found help here a few times. You've scared that right out of me..... umm.... thanks?
A reply falls below the community's threshold of quality. You may see it by logging in.