Hi all

Thank you for your responses. I just tried the following. Took me a few searches, I also happened to get the brackets wrong for the array....used [ instead of (... and then went "heck, [ is for anonymous arrays..." hahaha. The map and grep took google searches to get it flowing back.

C:\>more first.pl #use warnings; #use strict; my @arr = (1..10); foreach my $num (@arr) { print "Index is: $num. Value is: $arr[$num] "; } #Another way print "\nWith a C like for loop\n"; for($num = 0; $num<= $#arr;$num++) { print "Index is: $num. Value is: $arr[$num] "; } my @divbytwo = map { $_ / 2} @arr; print "\n\@divbytwo = @divbytwo\n"; my @divbytwoo = grep { $_ % 2 == 0} @arr; print "\@divbytwoo = @divbytwoo\n"; C:\>perl first.pl Index is: 1. Value is: 2 Index is: 2. Value is: 3 Index is: 3. Value i +s: 4 Index is: 4. Value is: 5 Index is: 5. Value is: 6 Index is: 6. V +alue is: 7 Index is: 7. Value i s: 8 Index is: 8. Value is: 9 Index is: 9. Value is: 10 Index is: 10. +Value is: With a C like for loop Index is: 0. Value is: 1 Index is: 1. Value is: 2 Index is: 2. Value i +s: 3 Index is: 3. Value is: 4 Index is: 4. Value is: 5 Index is: 5. V +alue is: 6 Index is: 6. Value i s: 7 Index is: 7. Value is: 8 Index is: 8. Value is: 9 Index is: 9. Va +lue is: 10 @divbytwo = 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 @divbytwoo = 2 4 6 8 10

I think I better start from scratch :)


In reply to Re: Good Perl book? by Anonymous Monk
in thread Good Perl book? by Anonymous Monk

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.