in reply to querybregarding array utils module in perl
Your second open is failing, and thus you don't know that @array1 is empty. It's probably better if your opens look more like: open(FILE,'<', $file) or die "Open fail on $file: $!"
Your input is literally 1,2,3,4 and so your arrays only have 1 element. In this case, you need to reformat your input files to be newline separated or feed the input through split.
The following code works for me.
#!/usr/bin/perl -w use strict; use Array::Utils qw(:all); my @first = (1,2,3,4); my @second = (1,5,6,7); my @minus = array_minus( @first,@second ); for my $term (@minus) { print "'$term'\n"; }
It outputs
'2' '3' '4'
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|