Solved

Searching part of a file

Posted on 1997-05-23
1
166 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 100 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

707 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