[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

simple question perl coding

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
abangbatax
Asked:
abangbatax
  • 2
  • 2
1 Solution
 
Adam314Commented:
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
 
abangbataxAuthor Commented:
/g = global match?
do i need it?

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

should i add /g ?
0
 
Adam314Commented:
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
 
abangbataxAuthor Commented:
thank you for your help!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now