Try this:
(use single quotes if you are not on Windows)perl -e "$var = shift; $var=~s/^($var)$/\u$1/;print $var;" hi
Note that the /e modifier only works on the substitution part of the regex, never on the pattern part. Adding /e, does not magically make shift get the argument out of the argument list.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
In reply to Re: use shift function in regex
by CountZero
in thread use shift function in regex
by suhailck
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |