I am still new to Perl as well. I want the end result to look like the following...
USERNAME FULLNAME COMPANY OWING username1 fullname1 company1 owing1 username2 fullname2 company2 owing2 and so on.... Then I need for a user to type in their username and I need my script to be able to extract the rest of the data such as if the user enters username1 as their username I need to display... fullname1 company1 owing1. Does this make sense? Regards, Dan -----Original Message----- From: Timothy Johnson [mailto:[EMAIL PROTECTED]] Sent: Tuesday, 26 March 2002 11:46 AM To: 'Matthew Harrison'; Daniel Falkenberg Cc: [EMAIL PROTECTED] Subject: RE: Can I set this as a hash? Or perhaps a list of lists... Maybe you should describe your HOH better. What do you want the end result to look like? -----Original Message----- From: Matthew Harrison [mailto:[EMAIL PROTECTED]] Sent: Monday, March 25, 2002 5:18 PM To: Daniel Falkenberg Cc: [EMAIL PROTECTED] Subject: Re: Can I set this as a hash? I know i'm still only learning perl so feel free to ignore me if i've said something stupid, but wouldn't tha be better as a list instead of a hash? On Tue, 26 Mar 2002, Daniel Falkenberg wrote: > Hello All, > > Just wondering how I would go about setting up the following hash and if > it would be wise to do it this way? > > I have the following data... > > $username $company $fullname $owing > > I want to place all of this in a hash of a hash... > > %name_of hash = > "Username1" => "Company1" => "$fullname1" => "$owing" > > So basically I want to populate the hash with the above data. Here is > there perl code I have so far... > > #!/usr/bin/perl -w > > use Data::Dumper; > > > $FILE_NAME = "vintekdb_query_250302.txt"; > $USER_DATA = "/var/www/cgi-bin/$FILE_NAME"; > > sub read_data { > open USER_DATA, "$USER_DATA" or warn "cannot open '$USER_DATA' for > reading: $!\n"; > flock(USER_DATA, 2) || warn "Can't lock $USER_DATA exclusively: $!"; > while( $USER_DATA=<USER_DATA> ) { > @USER_DATA = split (/,/, $USER_DATA); > s/^"|"$//g foreach @USER_DATA; > $username = $USER_DATA[0]; > $fullname = $USERDATA[1]; > $company = $USERDATA[2]; > $owing = $USERDATA[3]; > #CREATE HASH OF HASH HERE > } > } > close USER_DATA; > return %users; #NAME OF HASH > } > > read_data(); > > Does any one have any ideas on how I would go about this? Is this even > the best way to do something like this? > > Regards, > > Dan > > -- Matthew Harrison Internet/Network Services Administrator Peanut-Butter Cheesecake Hosting Services Genestate www.peanutbuttercheesecake.co.uk -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ------------------------------------------------------------------------ -------- This email may contain confidential and privileged material for the sole use of the intended recipient. If you are not the intended recipient, please contact the sender and delete all copies. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]