N. Ganesh Babu wrote:
Dear All
Hello,
I want to do capitalisation of this text. I am using the following code.
It works fine with all other lines.
$line="Level A (Grade 1 reading level)";
@words=split(/ /,$line);
for($i=0;$i<=$#words;$i++)
{
$words[$i]=~s!($words[$i])!\u\L$1!gi;
print "$words[$i]\n";
}
This code is showing the following error: The main reason I understood
is the presence of ( and ) in the text.
perl test.pl
Level
A
Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE (Grade)/ at
test.pl line 6.
Compilation exited abnormally with code 255 at Mon Apr 18 15:22:33
Please help me in this regard to solve this problem.
What you want is something like:
my $line = 'Level A (Grade 1 reading level)';
$line =~ s/([[:alpha:]]+)/\u\L$1/g;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>