You never put anything in $var, so unless you pass the empty string as an argument, it will never match.
\u$1 is not valid Perl code. \u is for use in string literals. So drop the "e" modifier.
By the way, the "g" modifier makes no sense either. How can ^ match more than once?
I think you meant
perl -le'($var = shift) =~ s/(.*)/\u$1/s; print $var' hi
But why the crazyness?
perl -le'print uc(shift)'
In reply to Re: use shift function in regex
by ikegami
in thread use shift function in regex
by suhailck
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |