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