Reputation: 1142
I have this function: Its supposed to just print through a custom linked list:
sub myprint {
my $iter = shift->{top};
my $refType = ref($iter);
while ($refType -ne "SCALAR") { #44
print $iter->{data};
$iter=$iter->{prev};
$refType = ref($iter);
}
}
errors:
jddancks@GIGABYTE-SERVER:/media/20B9-BF25/perl/OOP$ perl test_linked_list.pl
syntax error at cs351/linked_list/MyLinkedList.pm line 44, near "-ne"
Global symbol "$iter" requires explicit package name at cs351/linked_list/MyLinkedList.pm line 46.
Global symbol "$iter" requires explicit package name at cs351/linked_list/MyLinkedList.pm line 46.
Global symbol "$refType" requires explicit package name at cs351/linked_list/MyLinkedList.pm line 47.
Global symbol "$iter" requires explicit package name at cs351/linked_list/MyLinkedList.pm line 47.
syntax error at cs351/linked_list/MyLinkedList.pm line 48, near "}"
Compilation failed in require at test_linked_list.pl line 3.
BEGIN failed--compilation aborted at test_linked_list.pl line 3.
Upvotes: 0
Views: 55
Reputation: 240639
Never trust an error that comes after a syntax error.
On line 44, -ne
is an error, it should be ne
(you were probably thinking shell rather than perl).
Fix that, and the other errors will go away, or at least you will be left with another error that you can trust and do something about.
Upvotes: 4