CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
What might this function do?


New User

Feb 12, 2002, 2:32 PM

Post #1 of 2 (1427 views)
What might this function do? Can't Post

Can anyone maybe try to explain what this function is doing?

Especially what is in IDS finally? What is

  while (<$HFat>) { 

# prepares data structures for recNext

sub recAll {

local ($table) = @_;

undef %IDS;
($HData,$HFat) = &recOpen($table);
while (<$HFat>) {


return wantarray ? keys(%IDS) : '';


Feb 12, 2002, 4:27 PM

Post #2 of 2 (1423 views)
Re: [Alain] What might this function do? [In reply to] Can't Post

In that block, $HFat is a I/O-handle (most likely a handle to an opened file) and that handle is being iterated over, line by line (via the 'read-line' operator <>) and each line is being broken into two pieces separated by tabs: $id, and the $rest. Using the values a hash (or associative array, whatever floats your boat) is populated. %IDS is the hash being populated. It is being populated where you see the line:

$IDS{$id} = $rest;

So if the files that are being read, are just tables of data stored in text files, this subroutine is reading them into memory and storing them as hashes, which would provide quick access to the values in them, should that be desired.

Hope this helps!Smile



Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives