Ronnie Doorzon has asked for the wisdom of the Perl Monks concerning the following question:
into$line = '<br> 2<br> 3<br> 4';
The number of spaces can range from 0 to 50$line = '<br>  2<br>   3<br>    4';
sub convert_line_1 { my $line_convert = shift; $line_convert =~ s/(\s{5})/\ \ \ \  /g; $line_convert =~ s/(\s{4})/\ \ \  /g; $line_convert =~ s/(\s{3})/\ \  /g; $line_convert =~ s/(\s{2})/\  /g; return($line_convert); } sub convert_line_2 { my $line_convert = shift; $line_convert =~ s/     / /g; $line_convert =~ s/    / /g; $line_convert =~ s/   / /g; $line_convert =~ s/  / /g; return($line_convert); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Replace a word in a line except for the last char of the word?
by Roy Johnson (Monsignor) on Mar 11, 2005 at 12:03 UTC | |
by cog (Parson) on Mar 11, 2005 at 12:20 UTC | |
|
Re: Replace a word in a line except for the last char of the word?
by cog (Parson) on Mar 11, 2005 at 12:26 UTC | |
|
Re: Replace a word in a line except for the last char of the word?
by gube (Parson) on Mar 11, 2005 at 12:19 UTC | |
|
Re: Replace a word in a line except for the last char of the word?
by dmorelli (Scribe) on Mar 11, 2005 at 14:11 UTC | |
|
Re: Replace a word in a line except for the last char of the word?
by perlsen (Chaplain) on Mar 11, 2005 at 12:58 UTC | |
|
Re: Replace a word in a line except for the last char of the word?
by Ronnie Doorzon (Initiate) on Mar 11, 2005 at 14:38 UTC | |
|
Re: Replace a word in a line except for the last char of the word?
by PhilHibbs (Hermit) on Mar 11, 2005 at 15:40 UTC |