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; }
In reply to array references by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |