| 1 | package WWW::Translate::Apertium; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Carp qw(carp); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use URI::Escape; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use HTML::Entities; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Encode; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 3 | our $VERSION = '0.16'; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 3 | my %lang_pairs = ( | |||||||||||||||||||||||||||
| 17 | 'es-ca' => 'Spanish -> Catalan', # Default | ||||||||||||||||||||||||||||
| 18 | 'ca-es' => 'Catalan -> Spanish', | ||||||||||||||||||||||||||||
| 19 | 'es-gl' => 'Spanish -> Galician', | ||||||||||||||||||||||||||||
| 20 | 'gl-es' => 'Galician -> Spanish', | ||||||||||||||||||||||||||||
| 21 | 'es-pt' => 'Spanish -> Portuguese', | ||||||||||||||||||||||||||||
| 22 | 'pt-es' => 'Portuguese -> Spanish', | ||||||||||||||||||||||||||||
| 23 | 'ca-pt' => 'Catalan -> Portuguese', | ||||||||||||||||||||||||||||
| 24 | 'pt-ca' => 'Portuguese -> Catalan', | ||||||||||||||||||||||||||||
| 25 | 'gl-pt' => 'Galician -> Portuguese', | ||||||||||||||||||||||||||||
| 26 | 'pt-gl' => 'Portuguese -> Galician', | ||||||||||||||||||||||||||||
| 27 | 'es-pt_BR' => 'Spanish -> Brazilian Portuguese', | ||||||||||||||||||||||||||||
| 28 | 'oc-ca' => 'Occitan -> Catalan', | ||||||||||||||||||||||||||||
| 29 | 'ca-oc' => 'Catalan -> Occitan', | ||||||||||||||||||||||||||||
| 30 | 'oc-es' => 'Occitan -> Spanish', | ||||||||||||||||||||||||||||
| 31 | 'es-oc' => 'Spanish -> Occitan', | ||||||||||||||||||||||||||||
| 32 | 'oc_aran-ca' => 'Aranese -> Catalan', | ||||||||||||||||||||||||||||
| 33 | 'ca-oc_aran' => 'Catalan -> Aranese', | ||||||||||||||||||||||||||||
| 34 | 'en-ca' => 'English -> Catalan', | ||||||||||||||||||||||||||||
| 35 | 'ca-en' => 'Catalan -> English', | ||||||||||||||||||||||||||||
| 36 | 'fr-ca' => 'French -> Catalan', | ||||||||||||||||||||||||||||
| 37 | 'ca-fr' => 'Catalan -> French', | ||||||||||||||||||||||||||||
| 38 | 'fr-es' => 'French -> Spanish', | ||||||||||||||||||||||||||||
| 39 | 'es-fr' => 'Spanish -> French', | ||||||||||||||||||||||||||||
| 40 | 'ca-eo' => 'Catalan -> Esperanto', | ||||||||||||||||||||||||||||
| 41 | 'es-eo' => 'Spanish -> Esperanto', | ||||||||||||||||||||||||||||
| 42 | 'en-eo' => 'English -> Esperanto', | ||||||||||||||||||||||||||||
| 43 | 'eo-en' => 'Esperanto -> English', | ||||||||||||||||||||||||||||
| 44 | 'ro-es' => 'Romanian -> Spanish', | ||||||||||||||||||||||||||||
| 45 | 'es-en' => 'Spanish -> English', | ||||||||||||||||||||||||||||
| 46 | 'en-es' => 'English -> Spanish', | ||||||||||||||||||||||||||||
| 47 | 'cy-en' => 'Welsh -> English', | ||||||||||||||||||||||||||||
| 48 | 'eu-es' => 'Basque -> Spanish', | ||||||||||||||||||||||||||||
| 49 | 'en-gl' => 'English -> Galician', | ||||||||||||||||||||||||||||
| 50 | 'gl-en' => 'Galician -> English', | ||||||||||||||||||||||||||||
| 51 | 'br-fr' => 'Breton -> French', | ||||||||||||||||||||||||||||
| 52 | 'nb-nn' => 'Norwegian Bokmål -> Norwegian Nynorsk', | ||||||||||||||||||||||||||||
| 53 | 'nn-nb' => 'Norwegian Nynorsk -> Norwegian Bokmål', | ||||||||||||||||||||||||||||
| 54 | 'sv-da' => 'Swedish-Danish', | ||||||||||||||||||||||||||||
| 55 | 'es-ast' => 'Spanish-Asturian', | ||||||||||||||||||||||||||||
| 56 | 'is-en' => 'Icelandic-English', | ||||||||||||||||||||||||||||
| 57 | 'bg-mk' => 'Bulgarian-Macedonian', | ||||||||||||||||||||||||||||
| 58 | 'mk-bg' => 'Macedonian-Bulgarian', | ||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 3 | my %output = ( | |||||||||||||||||||||||||||
| 62 | plain_text => 'txtf', # default | ||||||||||||||||||||||||||||
| 63 | marked_text => 'txt', | ||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 3 | my %defaults = ( | |||||||||||||||||||||||||||
| 67 | lang_pair => 'ca-es', | ||||||||||||||||||||||||||||
| 68 | output => 'plain_text', | ||||||||||||||||||||||||||||
| 69 | store_unknown => 0, | ||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=23.2
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | 2 | my $class = shift; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | # validate overrides | ||||||||||||||||||||||||||||
| 77 | 2 | my %overrides = @_; | |||||||||||||||||||||||||||
| 78 | 2 | foreach (keys %overrides) { | |||||||||||||||||||||||||||
| 79 | # check key; warn if illegal | ||||||||||||||||||||||||||||
| 80 | 2 | ▶ | carp "Unknown parameter: $_\n" unless exists $defaults{$_}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | # check value; warn and delete if illegal | ||||||||||||||||||||||||||||
| 83 | 2 | ▶ | if ($_ eq 'output' && !exists $output{$overrides{output}}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$_ eq "output" and not exists $output{$overrides{"output"}}
MC/DC0%0/2
$_ eq "output" and not exists $output{$overrides{"output"}}
$_ eq "output"
not exists $output{$overrides{"output"}}
Truth table66%2/3
A and not(B)
A= $_ eq "output"B= not exists $output{$overrides{"output"}}
| |||||||||||||||||||||||||||||
| 84 | 0 | carp _message('output', $overrides{output}); | |||||||||||||||||||||||||||
| 85 | 0 | delete $overrides{output}; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | 2 | ▶ | if ($_ eq 'lang_pair' && !exists $lang_pairs{$overrides{lang_pair}}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$_ eq "lang_pair" and not exists $lang_pairs{$overrides{"lang_pair"}}
MC/DC0%0/2
$_ eq "lang_pair" and not exists $lang_pairs{$overrides{"lang_pair"}}
$_ eq "lang_pair"
not exists $lang_pairs{$overrides{"lang_pair"}}
Truth table66%2/3
A and not(B)
A= $_ eq "lang_pair"B= not exists $lang_pairs{$overrides{"lang_pair"}}
| |||||||||||||||||||||||||||||
| 88 | 0 | carp _message('lang_pair', $overrides{lang_pair}); | |||||||||||||||||||||||||||
| 89 | 0 | delete $overrides{lang_pair}; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | # replace defaults with overrides | ||||||||||||||||||||||||||||
| 94 | 2 | my %args = (%defaults, %overrides); | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | # remove invalid parameters | ||||||||||||||||||||||||||||
| 97 | 2 | my @fields = keys %defaults; | |||||||||||||||||||||||||||
| 98 | 2 | my %this; | |||||||||||||||||||||||||||
| 99 | 2 | @this{@fields} = @args{@fields}; | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 2 | ▶ | if ($this{store_unknown}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 0 | $this{unknown} = (); | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 2 | $this{agent} = LWP::UserAgent->new( agent => 'apertium2perl' ); | |||||||||||||||||||||||||||
| 107 | 2 | $this{agent}->env_proxy(); | |||||||||||||||||||||||||||
| 108 | 2 | $this{url} = 'http://xixona.dlsi.ua.es/webservice/ws.php'; | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 2 | return bless(\%this, $class); | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 0 | ▶ | sub translate { | ||||||||||||||||||||||||||
|
Subroutine
translate: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||
| 116 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 0 | my $string; | |||||||||||||||||||||||||||
| 119 | 0 | ▶ | if (@_ > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 0 | $string = shift; | |||||||||||||||||||||||||||
| 121 | } else { | ||||||||||||||||||||||||||||
| 122 | 0 | carp "Nothing to translate\n"; | |||||||||||||||||||||||||||
| 123 | 0 | return ''; | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 0 | ▶ | return '' if ($string eq ''); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 0 | $string = _fix_source($string); | |||||||||||||||||||||||||||
| 129 | 0 | $string = uri_escape_utf8($string); | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 0 | my $browser = $self->{agent}; | |||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 0 | my $source_lang = substr($self->{lang_pair}, 0, 2); | |||||||||||||||||||||||||||
| 135 | 0 | my $target_lang = substr($self->{lang_pair}, 3, 2); | |||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 0 | my $url = "$self->{url}?mode=$self->{lang_pair}&format=txt&text=$string"; | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 0 | ▶ | if ($self->{output} eq 'marked_text') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | 0 | $url .= "&mark=1"; | |||||||||||||||||||||||||||
| 141 | } else { | ||||||||||||||||||||||||||||
| 142 | 0 | $url .= "&mark=0"; | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 0 | my $response = $browser->get($url); | |||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 0 | ▶ | unless ($response->is_success) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | 0 | carp $response->status_line; | |||||||||||||||||||||||||||
| 150 | 0 | return undef; | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if (!defined $response) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | 0 | carp "Didn't receive a translation from the Apertium server.\n" . | |||||||||||||||||||||||||||
| 156 | "Please check the length of the source text.\n"; | ||||||||||||||||||||||||||||
| 157 | 0 | return ''; | |||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 0 | my $translated = _fix_translated($response->{'_content'}); | |||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 0 | $translated = decode_utf8($translated); | |||||||||||||||||||||||||||
| 163 | 0 | $translated = decode_entities($translated); | |||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if ($self->{output} eq 'marked_text') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 0 | ▶ | if ($self->{store_unknown}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | # store unknown words | ||||||||||||||||||||||||||||
| 170 | 0 | ▶ | if ($translated =~ /(?:^|\W)\*/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 0 | ▶ | while ($translated =~ /(?:^|\W)\*(\w+?)\b/g) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | 0 | $self->{unknown}->{$source_lang}->{$1}++; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 0 | return $translated; | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 53 | ▶ | sub from_into { | ||||||||||||||||||||||||||
|
Subroutine
from_into: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||
| 183 | 53 | my $self = shift; | |||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 53 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | 26 | my $pair = shift; | |||||||||||||||||||||||||||
| 188 | 26 | ▶ | if (!exists $lang_pairs{$pair}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | 0 | carp _message('lang_pair', $pair); | |||||||||||||||||||||||||||
| 190 | 0 | $self->{lang_pair} = $defaults{'lang_pair'}; | |||||||||||||||||||||||||||
| 191 | } else { | ||||||||||||||||||||||||||||
| 192 | 26 | $self->{lang_pair} = $pair; | |||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | } else { | ||||||||||||||||||||||||||||
| 195 | 27 | return $self->{lang_pair}; | |||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 4 | ▶ | sub output_format { | ||||||||||||||||||||||||||
|
Subroutine
output_format: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 200 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 4 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 203 | 1 | my $format = shift; | |||||||||||||||||||||||||||
| 204 | 1 | ▶ | $self->{output} = $format if exists $output{$format}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | } else { | ||||||||||||||||||||||||||||
| 206 | 3 | return $self->{output}; | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 0 | ▶ | sub get_unknown { | ||||||||||||||||||||||||||
|
Subroutine
get_unknown: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 211 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 0 | ▶ | if (@_ && $self->{store_unknown}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ and $self->{"store_unknown"}
MC/DC0%0/2
@_ and $self->{"store_unknown"}
@_
$self->{"store_unknown"}
Truth table0%0/3
A and B
A= @_B= $self->{"store_unknown"}
| |||||||||||||||||||||||||||||
| 214 | 0 | my $lang_code = shift; | |||||||||||||||||||||||||||
| 215 | 0 | ▶ | if ($lang_code =~ /^(?:br|ca|cy|en|eo|es|eu|fr|gl|is|nb|nn|oc|oc_aran|pt|ro|sv|bg|mk)$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | 0 | return $self->{unknown}->{$lang_code}; | |||||||||||||||||||||||||||
| 217 | } else { | ||||||||||||||||||||||||||||
| 218 | 0 | carp "Invalid language code\n"; | |||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | } else { | ||||||||||||||||||||||||||||
| 221 | 0 | carp "I'm not configured to store unknown words\n"; | |||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 0 | ▶ | sub get_pairs { | ||||||||||||||||||||||||||
|
Subroutine
get_pairs: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 226 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 0 | return %lang_pairs; | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 0 | ▶ | sub _message { | ||||||||||||||||||||||||||
|
Subroutine
_message: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 232 | 0 | my ($key, $value) = @_; | |||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 0 | my $string = "Invalid value for parameter $key, $value.\n" . | |||||||||||||||||||||||||||
| 235 | "Will use the default value instead.\n"; | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 0 | return $string; | |||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 0 | ▶ | sub _fix_source { | ||||||||||||||||||||||||||
|
Subroutine
_fix_source: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 241 | 0 | my ($string) = @_; | |||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | # fix geminated l; replace . by chr(183) = hex B7 | ||||||||||||||||||||||||||||
| 244 | 0 | $string =~ s/l\.l/l\xB7l/g; | |||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 0 | return $string; | |||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 0 | ▶ | sub _fix_translated { | ||||||||||||||||||||||||||
|
Subroutine
_fix_translated: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 250 | 0 | my ($string) = @_; | |||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | # remove double spaces | ||||||||||||||||||||||||||||
| 253 | 0 | $string =~ s/(?<=\S)\s{2}(?=\S)/ /g; | |||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 0 | return $string; | |||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 3 | 1; | |||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | __END__ | ||||||||||||||||||||||||||||