Hi all..
I need to add a subroutine to my format.pl which reads the database and compares 2 fields..
1) I want to see if the second(2) field is eq to $db_userid
2) See if the fifth(5) field is eq to "New"
If BOTH return true.. then to display a "You have New mail"
If niether or only one match.. then to display "No new mail"
This is what I have so far..
# --------------------------------------------------------
my ($line, @lines, @data, $output, $notify, $found, $new);
$new = "New";
open (DB, "<$db_file_name2") or &cgierr("error in modify_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
@lines = <DB>; # Slurp the database into @lines..
close DB;
LINE: foreach $line (@lines) {
if ($line =~ /^$/) { next LINE; } # Skip and Remove blank lines
chomp ($line);
@data = &split_decode($line);
if (($db_userid eq $data[1]) && ($new eq $data[5])) {
return $notify = "You have new mail!!";
}
else {
return $notify = "No new mail";
}
}
}
and call it using
everytime I run it.. I continuelly get the "No new mail" part..
I'm sure I'm close.. but not sure what to try next (pulling hair out)
Any help greatly appreciated
------------------
-----------
millsie
A smile a day...
keeps the viri' away.
[This message has been edited by millsie (edited November 23, 1999).]
I need to add a subroutine to my format.pl which reads the database and compares 2 fields..
1) I want to see if the second(2) field is eq to $db_userid
2) See if the fifth(5) field is eq to "New"
If BOTH return true.. then to display a "You have New mail"
If niether or only one match.. then to display "No new mail"
This is what I have so far..
Code:
sub html_notify { # --------------------------------------------------------
my ($line, @lines, @data, $output, $notify, $found, $new);
$new = "New";
open (DB, "<$db_file_name2") or &cgierr("error in modify_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
@lines = <DB>; # Slurp the database into @lines..
close DB;
LINE: foreach $line (@lines) {
if ($line =~ /^$/) { next LINE; } # Skip and Remove blank lines
chomp ($line);
@data = &split_decode($line);
if (($db_userid eq $data[1]) && ($new eq $data[5])) {
return $notify = "You have new mail!!";
}
else {
return $notify = "No new mail";
}
}
}
and call it using
Code:
$notify = &html_notify;everytime I run it.. I continuelly get the "No new mail" part..
I'm sure I'm close.. but not sure what to try next (pulling hair out)
Any help greatly appreciated
------------------
-----------
millsie
A smile a day...
keeps the viri' away.
[This message has been edited by millsie (edited November 23, 1999).]