Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Perl (http://www.go4expert.com/forums/perl/)
-   -   validation from atext file and adding to text file (http://www.go4expert.com/forums/validation-atext-file-adding-text-file-t340/)

Devashish_saha 31May2005 11:47

validation from atext file and adding to text file
 
I am new to perl . i have been given ap project to validation username and pssword form text file and store login date and login time to a text file . Ihave written a below code in which i have done the validation and i can show the logodte and time in the browser
but i canot the information in atext file pls help me out



#!/usr/bin/perl

use CGI;
$var=new CGI;
$username=$var->param("username");
$password=$var->param("password");




print "Content-type: text/html\n\n";



if (-e "/httpd/GuestDB/Emp.txt"){
open (example, "/httpd/GuestDB/Emp.txt") || die ("Could not open file <br> $!");

@text = <example>;


$flag = 0;
foreach $file1 (@text)

{


my ($data1, $data2)=split(":",$file1);

sub trim
{
my $string = shift;
for ($string)
{
s/^\s+//;
s/\s+$//;
}
return $string;

}

$user = trim($data1);
$pass = trim($data2);


if(($user eq $username) && ($pass eq $password))
{

$flag=1;

break;
}



}





my $now = localtime;


if ($flag eq 1)


{
print $username,$now;
}






# open (example1, ">/httpd/GuestDB/Log.txt") || die ("Could not open file $!");
# @db_lines1 = <example1>;




else {
print "Error ...";
}



}
close (example);

shabbir 31May2005 11:50

Re: validation from atext file and adding to text file
 
Quote:

but i canot the information in atext file pls help me out
can you explain what you mean by the above line.


All times are GMT +5.5. The time now is 13:59.