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

Re: remove spaces after join operation

by 2teez (Priest)
on Jul 26, 2013 at 13:54 UTC ( #1046517=note: print w/ replies, xml ) Need Help??


in reply to remove spaces after join operation

Hi lakssredhar,
A suggestions:
I need to print the column1 as a row outside the while loop so i used

... push @first_sentence,$arr[0]; }print join ' ',@first_sentence;
I was kind of thinking, why, push all the column 1 into an array variable, in work on the array outside the while loop.
what of if all work were done in the while loop? Like so:
use warnings; use strict; my $line; while (<DATA>) { my $part = (split)[0]; if (/[.()]/) { $line =~ s/\s*$//; $line .= $part; } else { $line .= $part . q[ ]; } } print $line; __DATA__ i o am o 2 o ( o but o ) o . o how o

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me


Comment on Re: remove spaces after join operation
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (15)
As of 2014-10-23 16:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (125 votes), past polls