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

  • SEARCH
  • Home
  • 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 8916281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:12:02+00:00 2026-06-15T05:12:02+00:00

I want to extract some elements from each line of a file. Below is

  • 0

I want to extract some elements from each line of a file.
Below is the line:

 #                 1150 Reading location  09ef38 data = 00b5eda4

I would like to extract the address 09ef38 and the data 00b5eda4 from this line.

The way I use is the simple one like below:

while($line = < INFILE >) {

    if ($line =~ /\#\s*(\S+)\s*(\S+)\s*(\S+)\s*(\S+)\s*(\S+)\s*=\s*(\S+)/) {
       $time = $1;
       $address = $4;
       $data = $6;
       printf(OUTFILE "%s,%s,%s \n",$time,$address,$data);
      }
}

I am wondering is there any better idea to do this ? easier and cleaner?

Thanks a lot!

TCGG

  • 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-15T05:12:04+00:00Added an answer on June 15, 2026 at 5:12 am

    Another option is to split the string on whitespace:

    my ($time, $addr, $data) = (split / +/, $line)[1, 4, 7];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to extract some numbers from the input line which is a string.
I want to extract some links from a XML document (links are in same
I'm new to python. I want to extract some text from the CNN website.
I want to extract out some specified columns from the matrix. My matrix being
I want to extract images from an PDF. I'm using iTextSharp right now. Some
I'm trying to extract data from an xml file. A sample of my code
I want to extract around 20 element types from some SVG documents to form
I need to extract some data from a webpage with php. The part that
i want to extract some text in certain website. here is web address what
I have some html files and want to extract only lines with containing these

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.