- or download this
s/(old)/preserve_case("new", $1)/ieg;
...
my $mask = $from & (' ' x length($from));
return uc($to) | $mask;
}
- or download this
# requires $" hasn't been altered
# 123456789_123456789_12345678 = 28
sub pc {uc$_[0]|$_[1]&$"x length pop}
- or download this
sub preserve_case {
my ($to, $from) = @_;
...
my $mask = join '', map /\w/ ? $_ & ' ' : "\0", split //, $from;
return uc($to) | $mask;
}
- or download this
(my $mask = $from) =~ s/(\w)|./ $1 ? $1 & ' ' : "\0" /egs;
- or download this
# requires $" hasn't been altered
# 123456789_123456789_123456789_123456789_123456789_ = 50
sub pc {(my$x=pop)=~s/(\w)|./$1?$1&' ':"\0"/egs;uc$_[0]|$x}
- or download this
sub preserve_case {
my ($to, $from) = @_;
...
return uc($to) | $mask;
}
- or download this
sub preserve_case {
my ($to, $from) = @_;
...
return uc($to) | ($from ^ uc $from);
}