LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-14-2012, 02:35 PM   #1
jmc1987
Member
 
Registered: Sep 2009
Location: Oklahoma
Distribution: Debian, CentOS, windows 7/10
Posts: 893

Rep: Reputation: 119Reputation: 119
Perl CGI scripting


I am playing around with perl cgi scripting and now I have came to an issue I can't get around.

Error message:
Quote:
username@server.com [~/public_html/cgi-bin]# ./register.cgi
Content-Type: text/html; charset=ISO-8859-1

Use of uninitialized value in exists at ./register.cgi line 19.
AnyDBM_File doesn't define an EXISTS method at ./register.cgi line 19
Here is the code
PHP Code:
#!/usr/bin/perl -w

use strict;
use 
Digest::MD5 qw(md5_hex);
use 
CGI qw(:standard);


print 
header;
my $username param('username');
my $first_name param('first_name');
my $last_name param('last_name');
my $email param('email');
my $passwd md5_hex(param('passwd'));



my %userinfo;
dbmopen (%userinfo,"/home/username/public_html/testing/userdata"0644) || die "Cannot open Database $!";
if (
exists $userinfo{$username}){
    print 
"<p>Username Exist! Registration FAILED!</p>";
}
else {
    
$userinfo{$username}="$username $first_name $last_name $email $passwd";
    print 
"Registration Successful!";
    print 
"<p>Thank you for registering!</p>";
}

dbmclose(%userinfo); 
So why would EXISTS not be difined?
 
Old 04-15-2012, 04:18 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
dbmopen ties the hash userinfo to the database, but you have not set how to handle. It assumes AnyDBM_File which is a dummy framework, so exists is not implemented.

So inserting use DB_File will solve it, but I'm not really sure this is the correct one.
PHP Code:
#!/usr/bin/perl -w

use strict;
use 
Digest::MD5 qw(md5_hex);
use 
CGI qw(:standard);
use 
DB_File;                    # <<== add this
... 
 
Old 04-15-2012, 04:40 AM   #3
jmc1987
Member
 
Registered: Sep 2009
Location: Oklahoma
Distribution: Debian, CentOS, windows 7/10
Posts: 893

Original Poster
Rep: Reputation: 119Reputation: 119
Quote:
Originally Posted by pan64 View Post
dbmopen ties the hash userinfo to the database, but you have not set how to handle. It assumes AnyDBM_File which is a dummy framework, so exists is not implemented.

So inserting use DB_File will solve it, but I'm not really sure this is the correct one.
PHP Code:
#!/usr/bin/perl -w

use strict;
use 
Digest::MD5 qw(md5_hex);
use 
CGI qw(:standard);
use 
DB_File;                    # <<== add this
... 
Okay thanks alot I'll see if I can work that out.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with perl modules declaration and perl/cgi script shifter Programming 9 02-24-2010 09:09 AM
php cgi scripting umarzuki Linux - Server 1 10-11-2009 05:28 AM
Perl CGI:Can't locate CGI.pm supermyself Programming 13 09-10-2007 06:22 AM
cgi and shell scripting, setting it up? GridX Programming 7 04-12-2004 11:01 PM
cgi perl : I cant get perl to append my html file... the_y_man Programming 3 03-22-2004 05:07 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration