Your LWP stuff looks fine, but you need to make a few changes to your regular expression syntax to change to make this work. Should get you started, but there's plenty of good documentation about using regular expressions about.
- you need to use the pattern-match operator =~, not just a plain = to match a $string;
ie:
$string =~ m/
- You need to capture something using the * modifier between the start and end of the comment you're looking for. A * just tells Perl to get as much 'something' (where something is the thing preceding the *) as possible. To get as much of anything as possible, use .*
ie:
$string =~ m/($start)(.*)($end)/
- The page that's coming back runs over lots of lines. By default, Perl only matches over one line to find a pattern. Use the /s modifier at the end of your regular expression to tell Perl to search over newline boundaries.
ie:
$string =~ m/($start)(.*)($end)/s
- Since the target webpage has got lots of pairs of matched comments, and because .* is 'greedy' (it takes as much stuff as possible while still matching a pattern), you'll get everything between the *first* $start and the *last* end. That's loads of stuff. Use the ? (non-greedy) modifier on .* to get just the first result item.
ie:
$string =~ m/($start)(.*?)($end)/s
- You don't need to put brackets around $start and $end, because in your programme, you already know what's in there. Brackets capture the stuff that's matched between them and save them, which you don't want to do.
ie:
$string =~ m/$start(.*?)$end/s
$result = $1;
A