Programming Wiki: Structures with arrays in perl

Programming Wiki : PerlStructures

WikiHomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register

Structures with arrays in perl


Creating A Structure
struct (ThisStructure =>
       my_var => '$',
       my_array => '@',

Adding stuff into our structre
   #Populate an array with information from a file
   #reads in each line of a text file into an array "file_stuff"
   open(FILE,"./my_text_file"); my @file_stuff = <FILE>; close FILE;

   my $foo = ThisStructure->new( my_var       => 'some text',
                                         my_array => [@$file_stuff],

Accessing (print) the array in the structure
    print @{$foo->my_array};

This syntax looked strange at first but works.

There are no comments on this page. [Add comment]

Powered by Wikka Wakka Wiki
Page was generated in 0.0148 seconds