Hi.
I would approach this as first identifying the appropriate lines. Once I had a line with "[[...]]" in it, I would split apart the stuff before and after the interesting section, namely the string between the brackets.
For example, putting code with data around your idea:
Code:
#!/usr/bin/perl
# @(#) p4 Demonstrate uc on isolated string.
use warnings;
use strict;
my($t1,$t2,$t3);
while ( <DATA> ) {
chomp;
# old pattern -- s/\[\[\b(\w)\]\]/[[uc($1)]]/eg;
# Check for [], isolate three parts, interested in $2.
# 1 2 3
# v vv vv v
if ( /^(.*\[\[)(.*)(\]\].*)$/ ) {
$t1 = $1; $t2 = $2; $t3 = $3;
$t2 =~ s/\b(\w)/uc $1/eg;
print " title after :$t2:\n";
print "$t1$t2$t3\n";
} else {
print " No match for :$_:\n";
}
print "\n";
}
__DATA__
No brackets.
[[simple string]]
Junk before [[a string with Indeterminate spacing within brackets]] ja.
[[ one 123 two ]]
[[]]
which produces:
Code:
% ./p4
No match for :No brackets.:
title after :Simple String:
[[Simple String]]
title after :A String With Indeterminate Spacing Within Brackets:
Junk before [[A String With Indeterminate Spacing Within Brackets]] ja.
title after : One 123 Two :
[[ One 123 Two ]]
title after ::
[[]]
If you don't understand something here, do some intermediate prints to see what is going on.
Best wishes ... cheers, makyo