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

Re: Appending lines starting with white space to the previous line

by sathiya.sw (Monk)
on Jan 07, 2009 at 09:47 UTC ( [id://734597]=note: print w/replies, xml ) Need Help??


in reply to Appending lines starting with white space to the previous line

One another way is.,
while(($_ = scalar <>)) { # remove the new line from that line. chomp; if ( /^\s+/ ) { # if there is no previous line then print the warning and cont +inue reading the next line., if ( not defined $cur_line ) { warn "continuation of no previous line\n"; next; } # since it is a continuation line, concatenate it with the previous +line., $cur_line.=$_; } else { # if the line does not contains the tab, then take that line a +s the current line., if (defined $cur_line) { # print the concatenated line. print $cur_line . "\n"; } # store the current line in the variable $cur_line = $_; } }
Sathiyamoorthy
  • Comment on Re: Appending lines starting with white space to the previous line
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-23 22:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found