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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now