I have some thing happening in a package that seems strange to me. Lets say I have a blank array @array = (); when I check if the array{hash} is defined that should not be. Then push to that array and check the number again the array shifts to the next number.
I hope the code explains it better...
#!/usr/bin/perl
use warnings;
use strict;
# add to @Foo::THING
push(@Foo::THING, { 'check' => '1',} );
# Should say "Some Thing"
Foo::check_THING(0)
? print "Some Thing\n"
: print "No Thing\n";
# Should say "No Thing"
Foo::check_THING(1)
? print "Some Thing\n"
: print "No Thing\n";
# add to @Foo::THING
push(@Foo::THING, { 'check' => '1',} );
# Check if it was added?
Foo::check_THING(1)
? print "Some Thing\n" # I think it should be this
: print "No Thing\n"; # But we get this
# Why is it 2?
Foo::check_THING(2)
? print "Some Thing\n" # WTF?
: print "No Thing\n";
package Foo;
our @THING = ();
sub check_THING {
my $id = shift;
defined $THING[$id]{check}
? return 1
: return 0;
}