On 6/19/2004 12:37 PM, Michelle Rogers wrote:

ok..still not working..maybe if i do it this way..

What exactly is not working? Are you getting an error?

here's the code i have for storing..
<snip>

#!/usr/bin/perl -w
use CGI qw(:standard);
   use Storable;
print "Content-type:text/html\n\n";

$sname=param('sname');
$spassword=param('spassword');


if (open(MYFILE,"c://studentdata//studentdata.db")) { #I haven't inserted the read part here, yet.# close(MYFILE);

You don't need to open the file with open; use the 'retrieve' method.

} else {

 %student = (
  student1=>{
   username => $sname,
   password => $spassword,
 },
);

   store \%studentlist, 'c://studentdata//studentdata.db';

 print "<h1><center>Student was added!</h1><P><P>";
  print "<form action='adminlogin.cgi' method='post'>";
   print "<input type='hidden' name='name' value='michelle'>";
   print "<input type='hidden' name='password' value='phonics'>";
   print "<input type='submit' value='Continue'>";
}
</snip>

Here is a working example:

#!/usr/bin/perl

use warnings;
use strict;

use Storable;

my %data = (
  student1 => {
    username => 'name',
    password => 'pass',
  },
);

store( \%data, 'data.db' );

%data = ();

my $data_ref = retrieve( 'data.db' );

use Data::Dumper;
print Dumper( $data_ref );

__END__

Randy.



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to