Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

GDBM_File with Tie function

by bheeshmaraja (Novice)
on Oct 17, 2012 at 08:49 UTC ( #999492=perlquestion: print w/ replies, xml ) Need Help??
bheeshmaraja has asked for the wisdom of the Perl Monks concerning the following question:

I have a simple getdata perl script which is used to get users First Name, Last Name and their email details. I'm getting these details from a file(test.txt). test.txt has 25 fields separated by "|" delimiter and I'm getting only 3 fields using my getdata script. I couldn't understand the behavior of this script. I need help in understanding the below script.

#!/opt/perl/5.8.0/bin/perl #ident "%W%" use CGI qw(:standard); use GDBM_File ; use POSIX qw(fcntl_h errno_h); use Getopt::Std; use Fcntl; $dbfile_exist = "no"; $arg1 = $ARGV[0]; # Argument 1 is the User ID. $dbmdatabase = "/home/bheeshmaraja/test.txt"; if (-f "$dbmdatabase") { $dbfile_exist = "yes"; } else { print "NULL"; exit 0; } tie %DBMDB, GDBM_File, $dbmdatabase, &GDBM_READER, 0400 or die "Couldn +'t tie NDBM file 'filename': $!; aborting"; untie %DBMDB;

test.txt contains 5176219 lines. Could anyone help me to understand why I'm getting only 3 fields instead of all 25 fields by providing User Id as an argument. Thanks in Advance... Bheeshmaraja

Comment on GDBM_File with Tie function
Download Code
Re: GDBM_File with Tie function
by moritz (Cardinal) on Oct 17, 2012 at 09:16 UTC

    Is the data format that GDBM_File uses compatible with your formats (CSV with | as delimiter)? I don't know very much about GDBM, but I'd be surprised if that was the case.

    If not, you need to read the contents of the file (Text::CSV_XS can help you with that), and if you want them to live in a GDBM file, insert them into one.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://999492]
Approved by Ratazong
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2014-09-23 00:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (208 votes), past polls