Hello all,

Will really appreciate help with this: I'm pulling my hair out with this
one.

I have a list of contents in the @contents array and the script finds those
headings in the html and adds anchors to them. The trouble is, the
substitution won't match when there's a question mark in the content item:

I've quoted the pattern in the if loop but it won't work in a subtitution.
Clearly the question mark is being treated as a regex operator (0 or1)
rather than the literal. So, items 2 and 3 on the list below are not being
matched - how do I quote the scalar $item, question marks and all, in the
substitution below?

Contents list:

Background
Why China needed asset management?
The scope of operation for AMCs in China?
Ongoing AMC business in China
Asset management as part of China's overall financial reforms
The persistent problem of China's SOEs
Foreign participation in China's asset management sector
Conclusion
Information sources

Script:

        foreach $item (@contents) {
            if (q/<p><b>$item<\/b><\/p>/) {

                my $abbrev = $item;
                $abbrev =~ s/(.....).*/$1/;
                $abbrev =~ s/ //g;
                print "$item\n";


                s/<li>${item}<\/li>/<li><a
href="\#$abbrev">$item<\/a><\/li>/;
                s/<p><b>${item}<\/b><\/p>/<br>\n<p><span class="fauxh3"><a
name="$abbrev">$item<\/a><\/span><\/p>/;

            }
            else { print "$item\n"; }
        }



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to