for (my $i = 0; $i < @$sqlinfo; $i++) { my $user = $sqlinfo->[$i]{user}; # @check_user previously initiated - check here against previously f +ound names to avoid showing duplicated to the screen next if "@check_user" =~ /(^|\s)$user(\s|$)/; my $number = sqlinfo->[$i]{number}; my $show = "<a href=\"call.pl?user=$user\">$user</a>"; my $first = sqlinfo->[$i]{first}; my $lastn = sqlinfo->[$i]{lastn}; my $tel = sqlinfo->[$i]{tel}; my $email = sqlinfo->[$i]{email}; # @number_check has been previously initiated before if ("@number_check" =~ /(^|\s)$number(\s|$)/ ) { # The $user values here are: Joe1 Mary1 Joe1 Mary1 from $user variab +le as an example, how to avoid showing duplicated values in $userfina +l # I am trying to show Joe1 and Mary1 I tried the code below but its +not working. #trying my %unique; if ($unique{$user}) { next; } $unique{$user} = 1; #end trying - if I use the above nothing shows. #here its still printing all the names ignoring unique names. print "<br>Print this to check if I only got unique user: *$user*<br> +"; # @userfinal has been previously initiated before $userfinal = "$userfinal<tr><td>$show</td><td>$lastn, $firs</td><td>$ +tel</td><td>$email</td></tr>"; } }
In reply to Duplicated values in a For Loop by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |