in reply to Help with substitution - - 15 Characters from the left
#!/usr/local/bin/perl -w use strict; my @data = ('client-up-to-,Doe,Smith , Inc, jwaters,pfloyd,jjoplin'); foreach my $line (@data) { chomp $line; my $beg_line = substr($line, 0, 14); my $name_field = substr($line, 14, 10); my $end_line = substr($line, 25); print "B: ~$name_field~\n"; $name_field =~ tr/,/ /; $name_field =~ s/\s*$//; print "A: ~$name_field~\n"; $line = "${beg_line}${name_field}${end_line}"; $line =~ tr/,/\t/; print "~$line~\n"; } __END__ B: ~Doe,Smith ~ #note space is still in at this point A: ~Doe Smith~ ~client-up-to- Doe Smith Inc jwaters pfloyd jjoplin~
|
|---|