in reply to Re: Remove similar elements in both the array
in thread Remove similar elements in both the array
@a = grep not exists $in_b{$_}, @a; @b = grep not exists $in_a{$_}, @b;
According to my perl:
I think you want:Not enough arguments for grep at j.pl line 14, near "@a;" Execution of j.pl aborted due to compilation errors.
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my @a = (2, 6.5 ,4, 3, 2, 7.5, 4.0); my @b = (2, 6.52 ,4.5, 7.05, 2.0, 4.1, 3); my %in_a; my %in_b; undef @in_a{@a}; undef @in_b{@b}; @a = grep {not exists $in_b{$_}} @a; @b = grep {not exists $in_a{$_}} @b; print Dumper(\@a); print Dumper(\@b);
|
|---|