http://www.perlmonks.org?node_id=1007165


in reply to Get hangman words from text file

The error Global symbol "@hangman" requires explicit package name... means that whatever code you are actually running is using strict but does not declare @hangman, perhaps via my or our. You can use diagnostics if you need more clarity on an error message. See Use strict warnings and diagnostics or die. Basic debugging checklist wouldn't hurt either.

Seeing as your demo code does not emit any errors and there is no such mention in the "along the lines of" code, you need to post the code you are actually running, so we can provide guidance. Your posted code is grossly in line with what you need to do, though my open would likely look more like open my $fh, '<', 'words.txt' or die "Open fail on words.txt: $!\n";


#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.