| jasear 2005-08-03, 3:49 pm |
| I have a program:
use strict ;
use DB_File ;
my %h ;
sub Compare
{
my ($key1, $key2) = @_ ;
"\L$key1" cmp "\L$key2" ;
}
# specify the Perl sub that will do the comparison
#$DB_BTREE->{'compare'} = \&Compare ;
tie %h, "DB_File", "astdb", O_RDWR, 0640, $DB_BTREE
or die "Cannot open file 'tree': $!\n" ;
# Cycle through the keys printing them in order.
# Note it is not necessary to sort the keys as
# the btree will have kept them in order automatically.
foreach (keys %h)
{ #print "$_=$h{$_}\n";
}
untie %h ;
The program reads through the database and prints the key and the corresponding value.
First of all I would be very very grateful if someone can explain what this program does. I have a rough idea. I have very little knowledge of perl I have used php a lot.
What i want to be able to do is given a key print out the corresponding value. This program is printing all the values but i want to print specific value. For example there is a key /08845241830/8339 i want to print out its specific value. Ive tried so many things it just doesnt work. Can someone help? |