in sed(1)
& vim(1)
, there are a set of 'operators' in the regex substitution syntax, \u
, \l
, \U
, & \L
. These translit characters to either lowercase, or uppercase. So if one were to type s/(*.)/\L\1/g
, it would translit the entire string to lowercase, theoretically.
Is there equivalent functionality in Perl? Is something or eqivalent like...
while(<>) {
s/(*.)/\L\1/g;
}
vaild?
Yes, all of them exist in Perl.
But your regex is invalid, I guess you want:
while(<>) {
s/(.*)/\L$1/g;
}
If you want to lowercased the whole string, I suggest you lc:
while(<>) {
$_ = lc $_;
}