Solved

adding stuff in string.....

Posted on 2000-04-15
7
212 Views
Last Modified: 2010-08-05
hi all

i have this string :
<li><a href="/anydir/anylink.html">any text for the link</a>

and i want to get this:
<li><a href="http://www.myserver.com/anydir/anylink.html">any text for the link</a>

do someone have any idea..???

tanks
popy
0
Comment
Question by:popy
7 Comments
 
LVL 3

Expert Comment

by:monas
ID: 2719017
$x = '<li><a href="/anydir/anylink.html">any text for the link</a>';

$x =~ s#(<a href=")(.*)#$1.'http://www.myserver.com/'.$2/ei;

print $x;
0
 
LVL 3

Expert Comment

by:monas
ID: 2719031
oops

$x = '<li><a href="/anydir/anylink.html">any text for the link</a>';

$x =~ s#(<a href=")(.*)#$1.'http://www.myserver.com/'.$2#ei;

print $x;
0
 

Author Comment

by:popy
ID: 2719051
Adjusted points from 100 to 150
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

Author Comment

by:popy
ID: 2719052
ok, thanks, but now subquestion, this line appear somewhere in the text, i reading text file, then i need to verifing if the line having this tag...
any sugestion...?

popy
0
 
LVL 84

Expert Comment

by:ozo
ID: 2719061
There's really no need for the (.*) .$2 and /e
0
 

Accepted Solution

by:
nmoldav earned 150 total points
ID: 2719067
If you're reading a file, then it should work as follows:

while (<FILE>) {
      if (m!<A\s+HREF="([^"]+"!i) {
            my $link = $1;
            s!HREF="$link"!HREF="http://www.myserver.com/$link"!i;
      }
}

# The if checks whether the pattern is present in the current line and the replace operator adds the server name to the link.
0
 
LVL 3

Expert Comment

by:monas
ID: 2719068
while($x = <FILE>){
  $num = ($x =~ s#(<a href=")#$1.'http://www.myserver.com/'#gei);
  # number of occurences is in $num;
}
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sending email via Perl on Windows 3 163
PERL export multiple query results to a JSON file 1 165
transpose into pipe delemited 8 69
Extract data from span tag 1 92
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 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