Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Can't access values in dbm text file (Read 1269 times)
Typo
New Member
*
Offline


I Love YaBB 2!

Posts: 1
Joined: Sep 3rd, 2010
Can't access values in dbm text file
Jun 18th, 2011 at 8:00am
Print Post  
I've reposted this as there was a bad typo in the last one. Anyway, the problem is I can't access the values in the text file. Following is the script:

#!/usr/bin/perl
use strict;
use CGI;
use CGI::Carp qw ( fatalsToBrowser );
use DB_File;
use Fcntl;
print"Content-Type:text/html\n\n";
my(%colors,$dbfile,%HASH,%hash);
my $dbfile="/home/users/public_html/cgi-bin/colors.txt ";
tie (%HASH, "DB_File", $dbfile)or die "Can't open $dbfile: $!\n";

my %colors;
print"$colors{'ffffff'}";
print"$colors{'000000'}";
print"$colors{'ff0000'}";
untie %hash

colors.txt is as follows

%colors=(
'ff0000' =>'red'
'000000' => 'black'
'ffffff' => 'white'
)

With no html added I get a 0(zero) on my browser screen. If I add any html anywhere on the page it appears and the zero goes away but am getting nothing from the text file. I tried putting the .txt file in the cgi-bin and also the httdocs area with the same results.
Huh
« Last Edit: Jun 18th, 2011 at 11:29am by Typo »  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint