Extract multiple value with delimiters from a string

Hi All,

I have a simple perl script that can extract the source code from a webpage like below:


use WWW::Mechanize;

my $page = WWW::Mechanize->new();
my $data = $page->res()->content();
print $data;

What actually in the $data is a single string that contain some data that are useful for me:

What I need to is extract the information of


Please send me your revised perl code for the task.

Thank you,

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Need to see the entire string
To see whether there is a separator, is the sata as it is represented one entry per line?
As arnold said, you don't provide us with enough $data to construct a good regex (or other means of extraction).
tindavidAuthor Commented:
I don't understand, you mean the data from get() is not good enough for program to extract data after a pattern of "
horse.asp?HorseNo", all I need is the T322, T323, T340 .....

If you cut and paste the perl code and run it you should see the output ,  the value in the data is come from the get("http://www.hkjc.com/chinese/racing/selecthorsebychar.asp?ordertype=2");

 what I want is to continue the code :  print $data

to search $data to extract all information from the $data

.......class=table_Text><a href="horse.asp?HorseNo=T322" ......
.......class=table_Text><a href="horse.asp?HorseNo=T333" ......
.......class=table_Text><a href="horse.asp?HorseNo=T340"........
It's not the data from the call as much as what data exactly you want extracted...

Is it always href="horse.asp?HorseNo=Txxx"?

Do you want HorseNo=Txxx or just Txxx (your original question said the former but this response sounds like the latter)?

This should at least be a good start...
use strict;
use warnings;
use WWW::Mechanize;

my $page = WWW::Mechanize->new();
my $data = $page->res()->content();
my @horses = $data =~ m{\shref="horse.asp\?HorseNo=(T\d+)"}g;
print join("\n", @horses), "\n";

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.