Programming Perl in C
Then a loop is run for count iterations calling hv_iternextsv(). The call takes 
three parameters, the HV* for the hash, a pointer to a char* to store the key, and a 
pointer to an integer to store the length of the key. The function returns an SV* for 
the value of this key.
Storing Values
Values are stored in a hash using the hv_store() function. For example, the 
following stores the value 100 under to key fuel_remaining in hv:
SV *sv_value = newSViv(100);
hv_store(hv, "fuel_remaining", strlen("fuel_remaining"), sv_value, 0);
The last value allows you to pass in a precomputed hash value; setting it to 0 tells 
Perl to compute the hash value for you. Notice that this function doesn't have the 
restrictions that av_store() does HVs grow automatically, and you don't have to 
extend them manually to store new values.
Deletion
An entire HV can be cleared with the hv_clear() function:
hv_clear(hv); // %hv = ();
Or you can use it to clear just a single key:
hv_delete(hv, "foo", strlen("foo"), 0); // delete $hv{foo}
Reference Values (RV)
In Perl, complex data structures are built using references. For example, if you 
want to create an array of hashes, you do it by assigning references to arrays as 
hash values:
%hash_of_arrays = (
   foo => [ 1, 2, 3 ],
   bar => [ 4, 5, 6 ],
);
In the Perl API, references are represented by SVs containing RV values. Much like SVs
can contain IV or PV values, SVs can also contain RV values that reference other objects.
18
189
9






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

web hosting perl

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved