cgi - Empty a dynamically created array in a Perl Module -


hi guys need regarding modules , emptying dynamically created array in module.

i have 1 perl file, , 2 perl modules ( have created )

//file.pl  use abc; use xyz;  for(qw/us uk china india france/) {    abc::fetchdata // create array varialbes    xyz::calculateyield      // use arrays dynamically created fetchdata     // @ point, when return want new copy of array used in xyz.pm's calculateyield function  } 

this example of abc.pm

//abc.pm package abc;  our @mainarray;  sub fetchdata {   // connect database , fill @mainarray;   @mainarray = qw/a b c d e f/;  }  1; 

this example of xyz.pm

//xyz.pm package xyz;  sub calculateyield {    foreach $eachelement ( @abc::mainarray)    {        push @{$eachelement), "some_data_that_changes_every_time_from india, uk, us, france or china";    }  } 

now, problem lies here, want empty out array "@{$eachelement}" after every call of for(1..5) , because $eachelement stays same in every count. value of data pushed push @{$eachelement) in xyz module changes depending on value ( us, uk, china, india, france).

question group is, there way empty out array in module name dynamically created. example want clear out @{$eachelement} in xyz.pm after everytime loop done.

hope have put in way can understood. if anyof have better solution or else can use,i willing that. ping me if question or part of code not clear.

ps : not looking small error or typo, sample code. want know how things can done.

thanks anticipated in advance.

i looked around , found solution particular problem. defined global function

sub clear {        $ref (values %msql::)      {         @{$ref} = ();     } } 

thanks guys support.

@patrick , not typo error. said looking logic.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -