Solved

simple question perl coding

Posted on 2008-06-09
4
184 Views
Last Modified: 2013-12-25
this source :
<br><a href='http://www.oracle.com/technology/obe/11gr1_db/appdev/php/files/errors.php' class='link_small'>http://www.oracle.com/technology/obe/11gr1_db/appdev/php/files/errors.php</a></td></tr>

how to crop in perl

the one statred from class='link_small'> and ended with </a>
resulted to this :
http://www.oracle.com/technology/obe/11gr1_db/appdev/php/files/errors.php

i have tried using this code:

$link =~ m/class=\'link_small\'?>http:\/\/(.+?)\<\/a>/g

is that correct? or any accurate coding?
0
Comment
Question by:abangbatax
  • 2
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
Adam314 earned 50 total points
ID: 21744807
I'm not sure what you are asking?  The code you have above does not include the "http://" in what is captured.  If you want to include that:
    m/class=\'link_small\'?>(http:\/\/.+?)\<\/a>/g

Also, the /g option is for a global match.  Unless this is going to appear more than once, you don't need that option.

A generally more reliable way to get info from HTML files is with an HTML parser.  In some cases a simple regex will work, but there are cases that will break the regex...

0
 

Author Comment

by:abangbatax
ID: 21745337
/g = global match?
do i need it?

i am scripting a web link grabber...  based on keyword

should i add /g ?
0
 
LVL 39

Expert Comment

by:Adam314
ID: 21746040
That depends on what you want.  If the content (what is in $link) can have the desired text appear multiple times, and you want to get all of them, then yes - use the /g.  
0
 

Author Closing Comment

by:abangbatax
ID: 31465461
thank you for your help!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now