Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Using Array::Diff

by Perlbotics (Archbishop)
on Dec 02, 2014 at 22:08 UTC ( [id://1109046]=note: print w/replies, xml ) Need Help??


in reply to Using Array::Diff

Array::Diff returns an array-reference, see the modified example below:

use warnings; use strict; use Array::Diff; use Data::Dumper; my @old = ( 'a', 'b', 'c' ); my @new = ( 'b', 'c', 'd' ); my $diff = Array::Diff->diff( \@old, \@new ); my $cnt = $diff->count; my $add_ref = $diff->added; # Array::Diff returns an array-referen +ce my $del_ref = $diff->deleted; print "cnt=$cnt\n"; print "add: ", Dumper( $add_ref ), "\n"; print "del: ", Dumper( $del_ref ), "\n"; print "add-list: ", @{$add_ref}, "\n"; print "del-list: ", @{$del_ref}, "\n"; __END__ cnt=2 add: $VAR1 = [ 'd' ]; del: $VAR1 = [ 'a' ]; add-list: d del-list: a

Log In?
Username:
Password:

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

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

    No recent polls found