[thelist] Perl: Writing to file not working...... (fwd)

Dean Mah dsmah at home.com
Fri Aug 10 09:42:12 CDT 2001

Didn't catch the original message as it was coming through so please
excuse the strange quoting.

> foreach $emailfile(@emailfile) { # Loops through for each record
>        ($new_email) = split(/\|/, $logemailfile);
>        $new_email = lc($new_email); # lowercase
>        $email = lc($email);         # lowercas

There seems to be something missing from this code.  You must be
defining some variables that you didn't show in the original message.
What and where is the value of $email and $logemail being set?

If you mean to use $emailfile instead of $logemailfile in your split,
that makes some sense.  But where is $email being defined and why to
do you keep forcing it to lowercase in the loop if it is defined
outside the loop?  That's inefficient...


> if('$new_email' eq '$email'){
>    last;
> }
> else{
>    $ok_to_log_email='1';
> }

This if statement will never return true.  You are using single quotes
around the variables $new_email and $email which compares the two as
literal strings.  You want to compare the values in the variables so
you should just use:

   if ($new_email eq $email)


   if ("$new_email" eq "$email")

should also work.

> if($ok_to_log_email == '1')

If you are comparing the string 1 to the variable, you should use the
eq operator rather than ==.


More information about the thelist mailing list