Hi, for clarity can you confirm that the three sections of the image you have posted are the question, the answer and an explanation?

If we take the first image you've posted it then it's correct to say that there will be no output to speak of. Clarity can be gained by adding use warnings; to the example code:

#!/usr/bin/perl use warnings; @this_array = ("b", "a", "d", "c"); foreach($this_array){ print("$_\n"); }

Which will return:

Use of uninitialized value $_ in concatenation (.) or string at derp.p +l line 7.

By simply changing the code to:

#!/usr/bin/perl use warnings; @this_array = ("b", "a", "d", "c"); foreach(@this_array){ # note @this_array not $this_array print("$_\n"); }

We now have working code which prints each item within the array. This is discussed in the third pannel (the explanation?). Out of curiosity is this a distance learning thing?


In reply to Re: Please Help With Perl by marto
in thread Please Help With Perl by JackVanson

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.