Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Comment on

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

You really need to review how data in perl works--you're not going to figure it out by hacking on the keyboard.

A couple procedural hints:

  • Insert print statements to print the values of variables so you can see what they contain. Sometimes they don't hold what you think they should. If you can't predict what values should be printed, then it's a sign that you don't understand something, and you need to learn it.
  • It'll be difficult to learn things if you're trying to learn them while writing a big program. If your attention is divided, you'll confuse yourself. Instead write tiny scripts to teach yourself individual concepts. Make them simple and easy to understand. Once you have a handle on the ideas, it's easier to use them in a larger piece of code.

For example, here's a little program you could have written to investigate hashes. Once you understand how it works, it'll be easier to work on your project.

$ cat t.pl #!/usr/bin/perl use strict; use warnings; use Data::Dumper; # some data to stick into the hash my $string1 = 'a'; # randomly generated my $string2 = 'f'; # randomly generated my $string3 = 'l'; # randomly generated my $string4 = 'g'; # randomly generated # stick them into the hash my %hashCheckLetter; $hashCheckLetter{$string1}=0; $hashCheckLetter{$string4}=0; $hashCheckLetter{$string3}=0; $hashCheckLetter{$string2}=0; # What does the hash actually have in it? print Dumper(\%hashCheckLetter); # what letters are in the hash? for my $letter ('a' .. 'h') { if (exists $hashCheckLetter{$letter}) { print "Found $letter!\n"; } else { print "Letter $letter not available\n"; } }

When run, it produces this:

$ perl t.pl $VAR1 = { 'l' => 0, 'a' => 0, 'g' => 0, 'f' => 0 }; Found a! Letter b not available Letter c not available Letter d not available Letter e not available Found f! Found g! Letter h not available

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re^7: Need help with Peal! by roboticus
in thread Need help with Peal! by ivanzhibin

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 scrutinizing the Monastery: (10)
    As of 2014-12-26 18:39 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

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





      Results (174 votes), past polls