Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

As for your code, the best place to start is by adding a couple of pragmas to your script. Please you ask and if I please to tell you these? Would it be so much to ask the names? or would it be a farce to tell? of what these pragmas are and when or where they may dwell? Why for a beginner the best place to begin is the start of the script with a couple of the most delightful pragmas known to exist. Their names? Their names? oh yes! my dear friend. Now, remember to put them at the beginning and not at the end. They're both written with u's and by you and if you don't use them someone will sue! So dont hesitate and stop your yawning the first of the pragmas is use warnings! did you get that? did you write that in your script? There's no time to waste here, now type use strict! There by golly and close by gosh we got this programme under the cosh!

#! /usr/bin/perl use strict; use warnings;

Right, so I think you may have to reconsider how your hash is constructed. The plural I would use in your script would be for the hash name. This is because the hash holds all the keys. Each of the keys is a singular key. And likewise each weight is associated to a key. So to tweak your hash a little, try something like

#! /usr/bin/perl use strict; use warnings; my %Elements; my $line = 'a,H,5'; my (undef, $symbol, $weight) = split /,/, $line; $Elements{$symbol} = $weight; my $requestelement = $Elements{'H'}; my $symbolweight = $Elements{$symbol}; print $requestelement,' ',$symbolweight; ---------- 5 5

You may now find accessing the hash values clearer. Make use of the strict and warnings messages to debug, its hard at first as the messages dont make a lot of sense but after a while you know what you have done. They do really help.


In reply to Re: Assistance please by Don Coyote
in thread Assistance please by R3volution

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (7)
    As of 2014-12-20 22:59 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (99 votes), past polls