Editing path in a HTML file using Perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Editing path in a HTML file using Perl
# 1  
Old 06-14-2013
Editing path in a HTML file using Perl

Hello

I want to replace the path to which a hyperlink points to. I have a html file

Code:
<TABLE BORDER CELLPADDING=7, border=0><TR><td>Jun-10-2013_03_19_07_AM</td><td>Ank_Insert_1</td><td><b>FAILED: 1</b></td><td><A 

href="C:\Some_WebServices\Results\Ankur\Static\Insert\Ankur_Insert_1_Static_Jun-10-2013_03_19_07_AM.xml">SoapRequest</A></td><td><A 

href="C:\Some_WebServices\Results\Ankur\Response\Insert\Ankur_Insert_1_Response_Jun-10-2013_03_19_07_AM.xml">SoapResponse</A></td><td><A 

href="C:\Some_WebServices\Results\Ankur\Dynamic\Insert\Ankur_Insert_1_Dynamic_Jun-10-2013_03_19_07_AM.xml">QueryResponse</A></td><td>1 ENU in 

R1</td></tr><TABLE BORDER CELLPADDING=7,

Now i want to change the path for example

from C:\Some_WebServices\Results\Ankur to E:\dummy\

here's what i have tried so far

Code:
foreach $line (@in){                 #for each element of the array
$line =~ s|'C:\Some_WebServices\Results\Ankur'|'E:\dummy\'|g;   


}

But it does not replace the old path. Although it works with normal string.
Any ideas why it's not working.

ThanksSmilie
# 2  
Old 06-14-2013
Code:
perl -pe 's#C:\\Some_WebServices\\Results\\Ankur#E:\\dummy#' filename

# 3  
Old 06-14-2013
Nope still no change occurs...
# 4  
Old 06-14-2013
How do you run this, it works for me.
Code:
echo '<TABLE BORDER CELLPADDING=7, border=0><TR><td>Jun-10-2013_03_19_07_AM</td><td>Ank_Insert_1</td><td><b>FAILED: 1</b></td><td><A
href="C:\Some_WebServices\Results\Ankur\Static\Insert\Ankur_Insert_1_Static_Jun-10-2013_03_19_07_AM.xml">SoapRequest</A></td><td><A
href="C:\Some_WebServices\Results\Ankur\Response\Insert\Ankur_Insert_1_Response_Jun-10-2013_03_19_07_AM.xml">SoapResponse</A></td><td><A
href="C:\Some_WebServices\Results\Ankur\Dynamic\Insert\Ankur_Insert_1_Dynamic_Jun-10-2013_03_19_07_AM.xml">QueryResponse</A></td><td>1 ENU in
R1</td></tr><TABLE BORDER CELLPADDING=7,' | perl -pe 's#C:\\Some_WebServices\\Results\\Ankur#E:\\dummy#'
<TABLE BORDER CELLPADDING=7, border=0><TR><td>Jun-10-2013_03_19_07_AM</td><td>Ank_Insert_1</td><td><b>FAILED: 1</b></td><td><A
href="E:\dummy\Static\Insert\Ankur_Insert_1_Static_Jun-10-2013_03_19_07_AM.xml">SoapRequest</A></td><td><A
href="E:\dummy\Response\Insert\Ankur_Insert_1_Response_Jun-10-2013_03_19_07_AM.xml">SoapResponse</A></td><td><A
href="E:\dummy\Dynamic\Insert\Ankur_Insert_1_Dynamic_Jun-10-2013_03_19_07_AM.xml">QueryResponse</A></td><td>1 ENU in
R1</td></tr><TABLE BORDER CELLPADDING=7,

This User Gave Thanks to Jotne For This Post:
# 5  
Old 06-14-2013
If you want to do changes in the input file itself , use option "i"
Code:
 
perl -i -pe 's#C:\\Some_WebServices\\Results\\Ankur#E:\\dummy#' filename

# 6  
Old 06-14-2013
Quote:
Originally Posted by pravin27
If you want to do changes in the input file itself , use option "i"
Code:
 
perl -i -pe 's#C:\\Some_WebServices\\Results\\Ankur#E:\\dummy#' filename

getting error

Can't do inplace edit without backup.
# 7  
Old 06-14-2013
This will take backup of your input file as "filename.bak" and then perform the action
Code:
perl -i".bak" -pe 's#C:\\Some_WebServices\\Results\\Ankur#E:\\dummy#' filename

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Editing HTML with FTP access

Hello, I've got a similar problem. I want to add some lines before the ending of the <head> tags. How can I do that? Example.<head> <some website stuff here> <My stuff> <head> I'd like to do that automatically with ftp. Is it possible to activate a sort of syncing in order to update... (4 Replies)
Discussion started by: danogentili
4 Replies

2. Shell Programming and Scripting

Input data of a file from perl into HTML table

Hi , I need an help in perl scripting. I have an perl script written and i have an for loop in that ,where as it writes some data to a file and it has details like below. cat out.txt This is the first line this is the second line. .....Now, this file needs to be send in mail in HTML... (2 Replies)
Discussion started by: scott_cog
2 Replies

3. Shell Programming and Scripting

Sizeof a file from directory path in perl

Hai how to find size of a file?? ex : /home/kiran/pdk/sample/calibre this is a path In that I have to find size of a files in side a calibre(it is the folder) like .results or .summary (1 Reply)
Discussion started by: kiran425
1 Replies

4. UNIX for Dummies Questions & Answers

Writing an HTML file in perl

I'm writing a perl script that writes an html file. use Tie::File; my ($dir) = @ARGV; open (HTML,">","$dir/file.html") || die $!; #-----Building HTML file--------------------------- print HTML "<!DOCTYPE html> <html> <head> <title>Output</title> <link... (3 Replies)
Discussion started by: jrymer
3 Replies

5. Shell Programming and Scripting

editing single line in html file in perl script

Hi Folks, It is regarding the perl scripting. I have an html file(many files) which contains the below line in the body tag. <body> <P><STRONG><FONT face="comic sans ms,cursive,sans-serif"><EM>Hello</EM></FONT></STRONG></P> </body> Now I want to read that html file through perl... (3 Replies)
Discussion started by: giridhar276
3 Replies

6. Programming

Minor editing of mass HTML files

Hello, I'm manipulating a batch of about 2,000 HTML files. I just need to make some small changes, but to all the files at once. For example, I want to delete the lines that have "embed_music" in all the files, or change all instances of the word "Paragraph" to "Absatz". This is my... (2 Replies)
Discussion started by: pxalpine
2 Replies

7. Shell Programming and Scripting

Is it possible to convert text file to html table using perl

Hi, I have a text file say file1 having data like ABC c:/hm/new1 Dir DEF d:/ner/d sd ...... So i want to make a table from this text file, is it possible to do it using perl. Thanks in advance Sarbjit (1 Reply)
Discussion started by: sarbjit
1 Replies

8. Shell Programming and Scripting

how to display the output file in an html format using perl

Hi, I have written a perl script to dispaly some statements from a file but i want the output statements to be dispalyed in an HTML format.Is it possible for me to do in perl scripting? Please help me with ur thoughts. Thanks In Advance Meva. (1 Reply)
Discussion started by: meva
1 Replies

9. UNIX for Dummies Questions & Answers

How to get file in the path by using perl

Hi, I had path like this abc/def/file it was assigned to one varible. i want to get the "file" from the above path by using perl appreciate the help!!! chaitanya. (4 Replies)
Discussion started by: chaitubek
4 Replies

10. UNIX for Dummies Questions & Answers

Editing $PATH in .bash_profile

Hello, I'm trying to add my bin directory to my path by editing the .bash_profile. I'm adding the following: PATH=$HOME/bin But then when I type in "echo $PATH" my bin directory is not added. Do I need to do something to make this take affect or am I going about this wrong. :confused: ... (9 Replies)
Discussion started by: Atama
9 Replies
Login or Register to Ask a Question