Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7938887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:55:53+00:00 2026-06-03T22:55:53+00:00

Given this file, I’m trying to do a super primitive sed or perl replacement

  • 0

Given this file, I’m trying to do a super primitive sed or perl replacement of a footer.

Typically I use DOM to parse HTML files but so far I’ve had no issues due to the primitive HTML files I’m dealing with ( time matters ) using sed/perl.

All I need is to replace the <div id="footer"> which contains whitespace, an element that has another element, and the closing </div> with <?php include 'footer.php';?>.

For some reason I can’t even get this pattern to match up until the <div id="stupid">. I know there are whitespace characters so i used \s*:

perl -pe 's|<div id="footer">.*\s*.*\s*|<?php include INC_PATH . 'includes/footer.php'; ?>|' file.html | less

But that only matches the first line. The replacement looks like this:

<?php include INC_PATH . includes/footer.php; ?> 
                   <div id="stupid"><img src="file.gif" width="206" height="252"></div>

               </div>

Am I forgetting something simple, or should I specify some sort of flag to deal with a multiline match?

perl -v is 5.14.2 and I’m only using the pe flags.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T22:55:55+00:00Added an answer on June 3, 2026 at 10:55 pm

    You probably want -0777, which will force perl to read the entire file at once.

    perl -0777 -n -e 's|something|else|g' file
    

    Also, your strategy of doing .*\s*.*\s* is pretty fragile. It’ll match e.g. <div id="foo", which is just a fragment…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given this XML: <mets:mets> <mets:fileSec> <mets:fileGrp ID=fileGrp001 USE=image/dynamic> <mets:file ID=filebib4112678_18760203_1_24_0001_m.jp2 MIMETYPE=image/jp2 SIZE=5308416 CREATED=2009-11-10T00:00:00 USE=image/dynamic
I have a feeling I'm being stupid. Given this ini file: [main] source1 =
Given this example XML file: <doc> <tag> Hello ! </tag> <tag> My name is
Given this piece of code : public static void writeFile(File file,List buffer)throws IOException{ File
I pasted the code given in this link to a file called md5.js. http://www.webtoolkit.info/javascript-md5.html
Given a Strong Name Key (snk file). Is there any security issues adding this
I wrote this script which counts occurrences of particular pattern in a given file.
This is my XML file <BADFM> <Given> <Ord> <Bag IDC=DM /> </Ord> </Given> </BADFM>
This is my jboss/deploy/postgres-ds.xml file. The connection url, username and password is given here.
Given a filename in C, I want to determine whether this file exists and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.