Chapter 8
   for (i = 0; i <= av_len(av); i++) {
      sv = av_shift(av);            // shift off the SV for this index
      string = SvPV(sv, len);       // get a stringified form of the SV
      printf("%s\n", string);       // print it out, one value per line
    }
Or, using av_pop(), create a version that prints them out in the reverse order:
   for (i = 0; i <= av_len(av); i++) {
      sv = av_pop(av);              // pop off the SV for this index
      string = SvPV(sv, len);       // get a stringified form of the SV
      printf("%s\n", string);       // print it out, one value per line
    }
Storing Values
The Perl API offers two ways to store values in an AV, av_store() and av_push(). For 
example:
SV *sv = newSVpv("foo", 0);
av_store(av, 9, sv);       // $av[9] = "foo"
This will work fine if you know the AV has room for a tenth element. If not, you need 
to first grow the array with a call to av_fill():
av_fill(av, 9); // set av s length to 9
This works the same as setting the $#array magic value in Perl it will truncate or 
grow the length of the array to the supplied value as required.
If you only need to add elements to the end of the array, av_push() offers a 
simpler solution. av_push() will automatically extend the array as it adds elements, 
so you don't need to call av_fill():
SV *sv = newSVpv("foo", 0);
av_push(av, sv);           // push(@av,"foo");
The Perl API does provide an av_unshift() function, but it doesn't work the 
same as the Perl unshift built in. Instead of adding elements to the front of the 
array, it only adds empty slots. You then need to fill those slots with av_store(). For 
example, to unshift the string  foo  onto an AV:
186






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