Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

HTML and Perl

Posted on 2002-06-03
6
Medium Priority
?
176 Views
Last Modified: 2010-05-18
I would like to make a copy of everything between the tag <title> and </title> and place it at the start of the opening body tag.  


Orginal file:
<html>

<head>


<title> This is my Web page

Please sign my guess book
</title>



<head>

<body>
The paragraphs in this script should not be touched.

I would like the spacing to be the same.

Can this be done.
</body>


Should look like this:

<html>

<head>


<title> This is my Web page

        Please sign my guess book
</title>



<head>

<body>
This is my Web page.

Please sign my guess book.

The paragraphs in this script should not be touched.

I would like the spacing to be the same.

Can this be done.
</body>

0
Comment
Question by:kennybud416
[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
  • 4
  • 2
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 7051893
s/(<title>(.*?)<\/title>.*?<body>)/$1\n$2/si;
0
 

Author Comment

by:kennybud416
ID: 7051962
can I run this from the command line? How do I specify the file name?
0
 

Author Comment

by:kennybud416
ID: 7052011
When I run the script is I get no out put?  I tried adding the line s/(<title>(.*?)<\/title>.*?<body>)/$1\n$2/si;print; to the end but it didn't display anything.

How would I specify the file name? What does the /si syntax mean?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:kennybud416
ID: 7052057
I have modified the script to look like this.perl -ane 's/(<title>(.*?)<\/title>.*?<body>)/$1\n$2/si;print;' 200206013032.xml

but it doesn't do any thing to the actual file? Am I doing something wrong?
0
 

Author Comment

by:kennybud416
ID: 7052150
Will the script still work .If the text in between the title tags are on more than one line?
0
 
LVL 84

Accepted Solution

by:
ozo earned 200 total points
ID: 7052159
perl -0777i.bak -pe 's/(<title>(.*?)<\/title>.*?<body>)/$1\n$2/si' 200206013032.xml
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
Six Sigma Control Plans

721 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