Hello Perl Monks. I am new to Perl Monks and somewhat new to Perl itself. I coded Java for a couple years and then stopped. I recently began working in networking and have been using a unix shell to do some stuff and decided to start learning perl. Anyways, I am writing a program just to learn a bit about hashes and the different operators that work on hashes. I have encountered a couple errors, and I have been scratching my head all morning to try and figure them out. Please let me know what you think. Sorry if this is should be completely obvious to me... as I said I'm relatively new to Perl.
#!usr/bin/local/perl %passwords = {"Matt", "s1k1d52", "scuzzy", "2ab928", "Marky", "s8291s" +, "Jeb", "jeb23"}; delete $passwords{"jeb"}; if(exists $passwords{"Matt"}){ print("$passwords{"Matt"} is my password."); } if(defined $passwords{"scuzzy"}){ print($passwords{"scuzzy"} . " IS defined!"); } print("%passwords are everyone's passwords!");
Bareword found where operator expected at passhash.pl line 9, near ""$ +passwords{"Matt" (Missing operator before Matt?) String found where operator expected at passhash.pl line 9, near "Matt +"} is my password."" syntax error at passhash.pl line 10, near "}" Missing right curly or square bracket at passhash.pl line 17, at end o +f line Execution of passhash.pl aborted due to compilation errors.
Also, it says that I have a curly cue missing but I counted an even amount... am I missing something? Thanks again.
In reply to hash problems by weglarz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |