Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^4: compare 2 arrays for intersect diff and commmon values

by rasgolla (Initiate)
on Mar 25, 2014 at 08:23 UTC ( [id://1079651]=note: print w/replies, xml ) Need Help??


in reply to Re^3: compare 2 arrays for intersect diff and commmon values
in thread compare 2 arrays for intersect diff and commmon values

Tangent Unfortuenetly there is no output. Also now I am unable to get device name now. I am pasting changed code again.I have tried putting debug statement as well but no output.Please let me know if it is correct. I a really thankful to you that you are giiving your preciosu time to me.

sub updatedevice() { my $n = {}; my %count; my $Device_LINK = $server->object("ICF_PersistentDataSet",$devicelinks +); my $Temp_Device_LINK = $server->object("ICF_PersistentDataSet",$tempde +vicelinks); my @current_devicelist = @{ $Device_LINK->invoke("get") }; my @temp_devicelist = @{ $Temp_Device_LINK->invoke("get") }; my %temp_list; my %current_list; my $size = @current_list; for ($n=0; $n < $size; $n++) { our $device=$current_list[$n][0]; $count{$device}++; } DEBUG( "DEBUG: - devicelinks values $device " ); my $size = @temp_list; for ($n=0; $n < $size; $n++) { our $tempdevicelinks=$temp_list[$n][0]; $count{$tempdevicelinks}++; } DEBUG( "DEBUG: - temp plc links values $tempdevicelinks " ); my @difference = grep { $count{$_} == 1 } keys %count; my @intersect = grep { $count{$_} == 2 } keys %count; my @union = keys %count; #DEBUG( "DEBUG Difference:\n"); #DEBUG( "DEBUG: - $_\n for @difference" ); #DEBUG( "DEBUG: - Intersect:\n "); #DEBUG( "DEBUG: - $_\n for @intersect "); #DEBUG( "DEBUG: - Union:\n "); #DEBUG( "DEBUG: - $_\n for @union " ); print "Difference:\n"; print "$_\n" for @difference; print "Intersect:\n"; print "$_\n" for @intersect; print "Union:\n"; print "$_\n" for @union;

Replies are listed 'Best First'.
Re^5: compare 2 arrays for intersect diff and commmon values
by tangent (Parson) on Mar 25, 2014 at 16:18 UTC
    Where does @current_list and @temp_list come from? They seem to be global variables declared elsewhere in your script. To see what they actually contain use Data::Dumper to print them out, and do the same for @current_devicelist and @temp_devicelist. Insert this code and come back with the results - and don't forget to use code tags:
    use Data::Dumper; test_updatedevice(); sub test_updatedevice { print Dumper(\@current_list); print Dumper(\@temp_list); my $Device_LINK = $server->object("ICF_PersistentDataSet",$devicelinks); my $Temp_Device_LINK = $server->object("ICF_PersistentDataSet",$tempdevicelinks); my $current_devicelist = $Device_LINK->invoke("get"); my $temp_devicelist = $Temp_Device_LINK->invoke("get"); print Dumper($current_devicelist); print Dumper($temp_devicelist); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1079651]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-19 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found