Find and delete a line, problems finding



I got my first PERL project last Monday and have written 3 pages of
working PERL, but 1 page is driving me nuts! I am very much a newbie,
so please have patience with me. below is a snippet of my code that is
having problems.

open(LISTFILE, "<.ccglist");
open(TEMPFILE, ">.tempfile");

while ($line=<LISTFILE>) {
print TEMPFILE $line unless $line =~ (/$accountnumber/ &&
/$effectivedate/);
}

close TEMPFILE; close LISTFILE;
unlink ".ccglist";
rename ".tempfile", ".ccglist";

I have finally got the deleting of a line working, but it is the
finding i am having a problem with. two problems really:
1) I need to search for a line that has the indicated account number
and effectivedate. I have found that this code will not take into
account the effective date.
2)I have tried without the effective date and it will find the
account number, but also finds any accounts that start with the account
number begining "pattern" as well. i need it find JUST the accounts
that match EXACTLY. e.g. user wants to delete account 123456, code
deletes 123456 AND 1234567.

Thank you so much for any suggestions. I love working in PERL and hope
to have more time to study it, but I need to turn this project in ASAP.
Thanks again!

.



Relevant Pages

  • Re: Find and delete a line, problems finding
    ... the language is called "Perl". ... told you that you're using an undefined value in the pattern matches. ... I need to search for a line that has the indicated account number ...
    (comp.lang.perl.misc)
  • Re: getpwnam question
    ... >>I am writing a perl program to lock the user ID if it exists in a file ... Is there a perl function to get ... > The property of an account being "locked" is a peculiarity of AIX, ... I know that you could lock accounts on DG/UX and I know you can on Linux. ...
    (comp.lang.perl.misc)
  • Re: Testing against a list of values ?
    ... You are practicing deceit, more succinct, you are ... and reputation as being amongst the worst of trolls spreading ignorance ... as it doesn't account for bad data. ... gave a talk at a conference, been hired to train people in perl or any ...
    (comp.lang.perl.misc)
  • Re: using modules
    ... many moons ago when I was a Perl ... module that is being found in my search path and not in the other search ... I've got a Perl program that runs fine from my account ... >> account, or when I telnet to another machine and try to run it, it ...
    (comp.lang.perl.misc)