Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Transforming a scalar to an array

by davorg (Chancellor)
on Jul 15, 2009 at 15:04 UTC ( #780349=note: print w/ replies, xml ) Need Help??


in reply to Transforming a scalar to an array

I realize that local( $/, *INPUT ); gets rid of the new lines.

It doesn't actually. You end up with a scalar that still has a newline at the end of each line of text. You can, of course, use that to your advantage.

my @lines = split /\n/, $input;
--

See the Copyright notice on my home node.

Perl training courses


Comment on Re: Transforming a scalar to an array
Download Code
Replies are listed 'Best First'.
Re^2: Transforming a scalar to an array
by ikegami (Pope) on Jul 15, 2009 at 15:19 UTC
    That's different from <> in that it will trim trailing blank lines (which is probably fine) and chomp all lines (which is probably fine).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (13)
As of 2015-07-29 21:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls