Solved

simple question perl coding

Posted on 2008-06-09
4
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Powershell PGP and SFTP 1 47
Secure registration PHP 7 39
php mail() send emails but the message is lost 4 33
Joomla Editing 3 21
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to count occurrences of each item in an array.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

732 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