Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Howto convert lines in stringified text into element of an array

by ikegami (Patriarch)
on Sep 04, 2007 at 03:55 UTC ( [id://636826]=note: print w/replies, xml ) Need Help??


in reply to Re: Howto convert lines in stringified text into element of an array
in thread Howto convert lines in stringified text into element of an array

Your solution truncates all trailing blank lines. That might be acceptable, but I'm mentioning it to let the OP (and other readers who might use this code) decide.
my $file; my @data_lines; while (<DATA>) { $file .= $_; chomp; push @data_lines, $_; } my @split_lines = split $/, $file; print(scalar(@data_lines), "\n"); # 3 print(scalar(@split_lines), "\n"); # 2 __DATA__ foo bar
  • Comment on Re^2: Howto convert lines in stringified text into element of an array
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2026-02-16 22:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.