string searching

Posted on 2002-06-05
Last Modified: 2010-05-18
here is what I want to do...

I have a flat file db with the following...



I want to remove an entry by email address... what can I use to test if is in a line, if so remove it.

@data = <file>;


foreach $line (@data) {


if (!($line contains {
 print newfile "$line\n";


Question by:msknr
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
LVL 84

Expert Comment

ID: 7057644
if( !($line =~ /\\E/) ){
    print newfile "$line\n";

Accepted Solution

jhurst earned 100 total points
ID: 7065004
if ($line !~ /,\"\"/i) {print $line}

is better for a couple of reasons:

a) it uses the !~ rather than doing the wrong test and then inverting it

b) the inclusion of the ,\" etc will ensure that an entry like: will not be recognized.  

c) the use of the /i at the end of the patern will ensure that the eMail address is case insensitive as it should be.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
perl script to check whether folder contains any files 5 104
Extract data from span tag 1 97
Able to retrieve only 1 row through email amongst multiple rows 3 101
perl syntax 3 52
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (,  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

736 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