in reply to array references

Well, line 24 is:

my @array=@{$neighbours{$domain}};

As @{...} is an array dereference, it would appear that $neighbours{$domain} is undefined. I can't tell more without seeing your input (and desired output), but you could at least bandage this with something like:

for my $domain(@domain){ next unless exists $neighbours{$domain}; my @array=@{$neighbours{$domain}};

Of course, this explicitly skips any element of @domain where %neighbours is uninitialized, which may be problematic for your case. You might also consider something like:

for my $domain(@domain){ my @array=exists $neighbours{$domain} ? @{$neighbours{$domain}} : +();

where this second option silently swallows domain misses. See perlreftut for more on references.

Replies are listed 'Best First'.
Re^2: array references
by Anonymous Monk on Jul 29, 2011 at 19:09 UTC

    thank you for your help, but it seams the first element in @domain doesnt come to process.

      I do not understand what you mean - see How do I post a question effectively?. Specifically, if your code is not behaving as expected, you should post sample input and expected output (both wrapped in <code> tags) so that we can replicate your issue.

      A good bug report is worth a thousand words.

        i have two file.one is 'result'

        AAA41250.1...........PF0000005.3 PF11001.3 PF00389.24 PF10417.3 AAA60129.1...........PF00389.24 PF11001.3 CAA00125.1...........PF00002.3 CAA79652.1........... CAB58510.1...........PF00389.24 PF0000005.3

        and i have another file 'domainlist'

        PF0000005.3 PF11001.3 PF00389.24 PF10417.3 PF00002.3

        as you said i am already studying perleftut, but still nothing :-(