http://www.perlmonks.org?node_id=986388


in reply to Re^2: C-Style Struct?
in thread C-Style Struct?

changed it, Thanks for your reminding.;)




I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

Replies are listed 'Best First'.
Re^4: C-Style Struct?
by Arunbear (Prior) on Aug 09, 2012 at 17:56 UTC
    But now I can see no advantage to using your example over just using a hash ;)

      But now I can see no advantage to using your example over just using a hash ;)

      No, My way is using a perl object to create a struct, every struct created by this has the same elements and spawned by the same creator.
      my %hash_1 = (number => 123, name => aa, stuff => \@xx); my %hash_2 = (number => 124, name => bb, stuff => \@yy); my %hash_3 = (number => 125, name => cc, stuff => \@zz); #if you chang +e struct, you have to change every instance. ..... ..... ..... my $aa = C_struct->new(123,'aa', [1,2,3]); my $bb = C_struct->new(234,'bb', [2,3,4]); #every instance is spawned +by the same object.