
tantalum
Novice
Feb 12, 2007, 6:24 AM
Post #10 of 17
(5737 views)
|
|
Re: [KevinR] Removing white spaces at the end of a string
[In reply to]
|
Can't Post
|
|
I tried kevins way but I must be messing something up... here is the code:
sub parse_line{ my ($line) = @_ ; @parts = split ",", $line ; foreach $n qw(1 2 3 4 6 7){ #get rid of the extra spaces in select columns $parts[$n] = s/\s+$// ; } return @parts ; } while(<STDIN>){ chomp $_ ; @my_line = parse_line $_ ; print join(',', @my_line), "\n"; } and I get this out put:
3,,,,,"MD",, 0,,,,,"Bel Air ",,,"714-978-2200" 1279,,,,,"MD",, 1003,,,,,"LA",, 1004,,,,,"MD",, it seems to be removing the whole string not just the white spaces....
|