in reply to get difference of two arrays

I was not able to run your programme (BTW, is it Estonian?). You should use variable names consistently ($quala is not $q is not $qa).

After fixing the errors, I just removed the square brackets around grep:

my @output = grep { ! exists $h{$_} } @a;

Square brackets introduce an anonymous array. You want a list, not an array reference, so no square brackets needed.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: get difference of two arrays
by naturalsciences (Beadle) on Nov 14, 2013 at 13:49 UTC
    Oh! Thanks. Yes it is Estonian :D. Somehow I posted even a more erroneus code that I have here working - (Probably trying to make it neat or remove some stuff - glad I did not remove the comments as it made it possible to use your lingusitics skill :D)
    #!/usr/bin/perl -w use strict; use warnings; use Data::Dumper; #kaks üheveerulist faili, prindib need veerud mis ühes on aga teises p +ole #ehk siis suurem fail miinus väiksem my $num_args = $#ARGV + 1; if ($num_args != 3) { print "\nUsage: ./lahutaja suurem väiksem vahe(output)\n"; exit; } my $fasta=$ARGV[0]; my $quala=$ARGV[1]; my $out=$ARGV[2]; open FA, "< $fasta"or die "Can't open $fasta: $!"; open QA, "< $quala" or die "Can't open $quala: $!"; open OUT,"> $out" or die "Can't open $out: $!"; my @bl = <QA>; my @a = <FA>; my %h; @h{@bl} = @bl; my @output=[grep {!exists $h{$_}} @a]; print Dumper @output ; print OUT @output; close FA; close QA; close OUT;
    was the original half-working piece