Best way to prevent output of a duplicate item in Perl in realtime during a loop -
I have to show a lot of 'related' questions, but no one has seen the answer to this specific scenario.
During some time / which parse results set generated by a SQL selection statement, what is the best way to prevent the next line from being output if that line already had the same field data (It is 1 for example, if there were two lines:
('EML-E', 'jsmith@mail.com', 'John', 'Smith') ( 'EML-E', 'Jasmith 2 @mail dot com', 'John', 'Smith') The best way to print only the first line What is the basis of the fact that 'EML-E' is similar in both lines?
Right now, I am doing this:
- Store the first field In the 2-element array (Dupakec [1])
- If duplex [0] = duchach [1] ('s' using duplicate-escape loop)
- < After processing the P> line, repeat [0] = set duplicates [1]
while ($ DBS- & gt; SQLft) == * Plibada :: radios] {$ S = 0; ($ I! = $ Array_len and $ s == 0) {$ rowfetch = $ DBS- & gt; {Cry} - & gt; #s = 1 to exit the GetCharValue ($ array_col [$ i]); If ($ i == 0) {$ dupecatch [1] = $ rowfetch;} # Duplicate duplicate primary key prevents field entries if ($ Dupake [0] has $ Dupake [1]) {dozoming ($ rowfault); } And {$ s ++;} $ i ++; } $ I = 0; $ Dupecatch [0] = $ dupecatch [1]; }
This is the standard way if you only Cares about duplicate items in a line, but $ duchech [0] is usually named $ old and $ duchach [1], usually only the variable in question. You can tell that the array is not a good fit because you only reference its index.
If you want to avoid all duplicates, you can see% hash:
my% visited; While (defined (my $ line = get_data ())) {if $ $ was viewed {$ row-> [0]} ++; # Skip all things, but the first example of key do_stuff (); }
Comments
Post a Comment