Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks.i have a error that i dont understand what is it? please help me.
the error is :cant use an undefined value as an ARRAY reference in line 24.#!/usr/bin/perl -w use strict; my @AoA; open (IN,'<result'); while(<IN>){ my @chunks = split; push @AoA, [ @chunks[1..$#chunks]]; } my %neighbours; for my $domain (@AoA) { for my $idx (0 .. $#$domain) { my @near = grep {$_ >= 0 && $_ <= $#$domain} $idx - 1, $idx + +1; push @{$neighbours{$domain->[$idx]}}, map {$domain->[$_]} @nea +r; } } open (DOMAINLIST,'<domainlist') or die "cannot open 'domainlist'becuas +e:$!"; chomp(my @domain=<DOMAINLIST>); for my $domain(@domain){ my @array=@{$neighbours{$domain}}; @array=removeduplicates(@array); my $number=scalar @array; print "Domain $domain.......$number\n"; } sub removeduplicates{ my @array=@_; my %seen; $seen{$_}++ for @array; my @unique = keys %seen; return @unique; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: array references
by kennethk (Abbot) on Jul 29, 2011 at 18:48 UTC | |
by Anonymous Monk on Jul 29, 2011 at 19:09 UTC | |
by kennethk (Abbot) on Jul 29, 2011 at 20:20 UTC | |
by Anonymous Monk on Jul 29, 2011 at 20:42 UTC | |
by Anonymous Monk on Jul 29, 2011 at 20:48 UTC | |
|