Hi monks,
Background
I have a set of values an array. Array can be
@names = qw(user_name house_name street_address phone_number date_of_birth);
I need to remove the "_" from all the values and need to have upper case for all words in each values.
The output I need is
User Name House Name Street Address Phone Number Date Of Birth
The Question
I tried to write something like
At the line $name =~ s/\_(\w)/\ uc($1)/g; Can I replace the "_" and next character with " " and return value of the function 'uc()', which takes $1 as parameter.foreach $name ( @names ){ $name = ucfirst($name); # made first letter $name =~ s/\_(\w)/\ uc($1)/g; # Here is the point. print "$name \n"; }
Update: Removed comas from the array as its a bug pointed out by pKai at Re: Interpolation inside regex
In reply to Interpolation inside regex by vc_will_do
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |