Emptying array inside loop while using push in PERL -


I am writing a subtitle that prints an array of non-redundant elements from another array.

This code is inside my suburban area. (code) $ {$ _ $}; } Print "@NewTable" "\ N";

Then I call my work in a loop inside my main program, it is fine to run first and in my new table there is an event of my old table but its The latter keeps @new_table elements from previous iteration and the print result is false.

I tried to clear @new_table inside my suburban area like this

  @new_table = (); Foreign currency (@old_table) {push (@ new_betable, $ _) unless that ($ $ {$ $} $ $ $ has been seen); } Print "@NewTable" "\ N";   

But then my @new_table becomes empty in all iterations except the first one.

What is the problem with this and how can I fix it?

Due to incorrect scrolling, you saw @new_table and % Make these loops before the past.

  my @new_table; My% looked; Foreign currency (@old_table) {push (@ new_betable, $ _) unless that ($ $ {$ $} $ $ $ has been seen); } Print "@ new_table" "\ N";   

It can be simplified to see my%

 ; My @new_table = grep {! $ Saw {$ _} ++} @old_table; Print "@New_Betables \ n";   

You can also use

  Usage list :: MoreUtils qw (uniq); My @new_table = uniq (@old_table); Print "@New_Betables \ n";   

You are using strict; use caution; , right? If not, you should be. always.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -