http://www.perlmonks.org?node_id=1086814

eyekona has asked for the wisdom of the Perl Monks concerning the following question:

At the moment I have this code snippet...
#!/usr/bin/perl while(<>) { chomp; s/^\s+//; s/\s+$//; next if /^$/; #Next if empty... #do something with the text copied to this loop... #just to do something as an example... print "$_ \n"; }
It's working fine and is doing what I want it to do - with one little exception... If I copy not just one line but multiple lines to the loop, it just prints the first of this lines. If i want it to print more of this lines I have to press enter repeatedly till it is done... if I copy or write anything to he loop until the lines are all done it mixes them up... But I want it to be able to process more then one line at a time - example: What it does:
#1st Example a #input (a) a #output #2nd Example a #input (a newline b pasted to the loop) ba #input and output #press enter b #output #3rd Example a #input (a newline b pasted to the loop) ba #input and output c #input (c) bc #output and output
What I want it to do:
a #input a #output a #input (a newline b pasted to the loop) b #continuing a #output b #without pressing enter again
Problem is - I'm not sure what to change because I can't find out why this is happening... Any idea?