Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Searching part of a file

Posted on 1997-05-23
1
Medium Priority
?
181 Views
Last Modified: 2013-12-25
I was wondering if anyone knows where i could
find a script, or knows the procedure that would allow
me to search parts of *one* file for string. I.e. We have a list of names with an email address and would like to be able to have an engine search inside the file for the names instead of searching for a file with the names.. Thanks in advance :)
0
Comment
Question by:Primetyme
[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
1 Comment
 
LVL 5

Accepted Solution

by:
icd earned 300 total points
ID: 1828086
Assuming your file is of the form

email@somewhere.com,fred bloggs

then you can search it with a perl script similar to:-

open (FID, "filename.txt");
while (<FID>) {
  chop;
  ($email, $name) = split(/,/, $_);
  if ($name eq $theNameIAmLookingFor) {
    print "The email you want is $email\n";
  }
}
close(FID);

Alternatively if it is a Unix host you could use a grep program.

0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

610 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