Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: printing out tabs between each element in an array

by olus (Curate)
on Feb 18, 2008 at 13:33 UTC ( [id://668533]=note: print w/replies, xml ) Need Help??


in reply to printing out tabs between each element in an array

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

Replies are listed 'Best First'.
Re^2: printing out tabs between each element in an array
by johngg (Canon) on Feb 18, 2008 at 14:15 UTC
    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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-03-28 13:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found