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 8445833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:45:46+00:00 2026-06-10T09:45:46+00:00

I have a large file that looks something like this: <Feed stack_overflow> sourceid 32456

  • 0

I have a large file that looks something like this:

<Feed stack_overflow>
   sourceid 32456
   prefeed 1
   <LOG>
     level 1
     cache info
  </LOG>
</Feed>

I want to do a search for anything in this file, and retrieve everything included the Feed tags. So if i do a search for 32456 i will get everything in the code above.

The code i have now is:

#!/usr/bin/perl
my $input = "<Feed stack_overflow"; #Search string
my $end = "</Feed>"; #End string
open (DATA, "file.config") or die "Error";

my @list = grep /\b$input\b(.*?)\b$end\b/, <DATA>;
chomp @list;
print "$_\n foreach @list;

But i don’t get any results, even tough I know what i search for exist.
I have successfully managed to print out every line containing a specific string with this regex:

my @list = grep /\b$input\b/, <DATA>;

But i need help on printing out everything between two tags.

  • 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-10T09:45:48+00:00Added an answer on June 10, 2026 at 9:45 am

    Your regular expression works with the data line by line, but your string spans over several lines. You can use the range operator:

    while (<$DATA>) {
        print if /$input/ .. /$end/;
    }
    

    If you want to exclude the border lines, you can change the inner line to

    print if (/$input/ .. /$end/) !~ /^1$|E0/}
    

    DATA is a predefined file handle. Consider using a different name, or use a lexical file handle (as $DATA in my example).

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

Sidebar

Related Questions

I have a large ARFF file with data that looks something like this: 555,2011-03-13
I have a large xml file that looks like this: 20120124 07:30:15.301, saving to
I have a very large defaultdict(dict) that looks something like this: data['w']['x']['y']['z']={'a':5,'b':10} I'm trying
I have a large file (2GB) which looks something like this: >10GS_A YTVVYFPVRGRCAALRMLLADQGQSWKEEVVTVETWQEGSLKASCLYGQLPKFQDGD LTLYQSNTILRHLGRTLGLYGKDQQEAALVDMVNDGVEDLRCKYISLIYTNYEAGKD
We have some html that looks like this: <form id=MyUserControl runat=server method=post> <script language=javascript
I large messy data files that look something like this: 1 2 3 4
I have data that looks like this: token eps rank # first line names
I have a large file that needs to be processed before feeding to another
I have a large JSON file that contains A LOT of similar code. It's
I have a large config file (user) that i needed to go to the

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.