Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Space prepended to Array Print

by grondilu (Friar)
on Jun 08, 2013 at 07:46 UTC ( #1037808=note: print w/replies, xml ) Need Help??

in reply to Space prepended to Array Print

Other comments above give you the explanation on what happened.

Me, when I want to put the lines of a text file in an array, I usually write:

my @data = map { chomp; $_ } <>;

And when I want to output it, I write:

print "$_\n" for @data

In Perl6 I'd write:

my @data = lines; .say for @data;

Replies are listed 'Best First'.
Re^2: Space prepended to Array Print
by choroba (Bishop) on Jun 08, 2013 at 07:57 UTC
    A bit faster is to use chomp for the array:
    chomp(my @data = <>);
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1037808]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2018-03-25 04:34 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (300 votes). Check out past polls.