On Mon, Nov 22, 2010 at 05:57:10PM +0000, Gary Stainburn wrote:
> Hi folks,
>
> I've done some googling but haven't found anything that (a) does what i want
> or (b) I understand.
>
> I've got the following code repeated thoughout a program I'm writing. I'm
> using www::Mechanize but because of extensive javascript usage on the web
> site I'm accessing I'm having to do a lot of manual HTML parsing.
>
> The code is:
>
> foreach (split(/\n/,$html)) {
> if (/HREF="(.*)".*SomeDisplayText/) {
> $URL=$1;
> last;
> }
>
> Is there a way I can change this to a sub and pass the HTML string and the
> regex as arguments?
What you are looking for is the qr// operator. See Regexp Quote-Like
Operators in perlop.
Come back if you need more help and I'm sure you'll get it.
--
Paul Johnson - [email protected]
http://www.pjcj.net
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/