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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.