Loading ...
Sorry, an error occurred while loading the content.

Newbie in Perl class > I don't understand the task

Expand Messages
  • Karen Nadalin
    I m a bit desperate to locate a resource that can help me understand this assignment. I ve plowed through a number of reading assignments, searched online to
    Message 1 of 4 , Sep 29, 2008
    • 0 Attachment
      I'm a bit desperate to locate a resource that can help me understand
      this assignment. I've plowed through a number of reading assignments,
      searched online to understand "for loop" and I still don't quite get
      what I' supposed to do. I need a push in the right direction.

      Task:
      Start with an array (1, 2, 3, 4, 5) and use a for loop to get the
      array to be equal to (1, 2, 3, 4, 5, 6, 7, 8). Display the result.

      If anyone has a resource or helpful tip so I can understand what I'm
      to do, I thank you.
      Karen
    • Karen Nadalin
      Okay, this is what I came up with (a little better understanding), but where is for loop in this? @array = 1..5; $a = @array; $b = push @array, 6..8; print
      Message 2 of 4 , Sep 30, 2008
      • 0 Attachment
        Okay, this is what I came up with (a little better understanding), but
        where is "for loop" in this?

        '@array = 1..5;
        $a = @array;
        $b = push @array, 6..8;
        print "@array";'

        TIA,
        Karen

        --- In perl-beginner@yahoogroups.com, "Karen Nadalin" <kznadalin@...>
        wrote:
        >
        > I'm a bit desperate to locate a resource that can help me understand
        > this assignment. I've plowed through a number of reading assignments,
        > searched online to understand "for loop" and I still don't quite get
        > what I' supposed to do. I need a push in the right direction.
        >
        > Task:
        > Start with an array (1, 2, 3, 4, 5) and use a for loop to get the
        > array to be equal to (1, 2, 3, 4, 5, 6, 7, 8). Display the result.
        >
        > If anyone has a resource or helpful tip so I can understand what I'm
        > to do, I thank you.
        > Karen
        >
      • merlyn@stonehenge.com
        ... Karen I m a bit desperate to locate a resource that can help me understand Karen this assignment. I ve plowed through a number of reading assignments,
        Message 3 of 4 , Sep 30, 2008
        • 0 Attachment
          >>>>> "Karen" == Karen Nadalin <kznadalin@...> writes:

          Karen> I'm a bit desperate to locate a resource that can help me understand
          Karen> this assignment. I've plowed through a number of reading assignments,
          Karen> searched online to understand "for loop" and I still don't quite get
          Karen> what I' supposed to do. I need a push in the right direction.

          Karen> Task:
          Karen> Start with an array (1, 2, 3, 4, 5) and use a for loop to get the
          Karen> array to be equal to (1, 2, 3, 4, 5, 6, 7, 8). Display the result.

          This is not a clueful exercise.

          First, do they want a "for loop" or a "foreach loop"? Have they taught the
          for loop yet (with for (initialize; test; increment) {...})?

          And if this is the full instructions, there are millions of possible
          solutions, one of which is:

          @anArray = (1, 2, 3, 4, 5);
          for (; $anArray[-1] < 8;) {
          push @anArray, 6, 7, 8;
          }

          This is not likely what they are asking for, but it's hard to tell what they
          *are* asking for.

          --
          Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
          <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
          Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
          See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
        • Jenda Krynicky
          From: Karen Nadalin ... Maybe they meant my @array = (1, 2, 3, 4, 5); for(my $i = 6; $i
          Message 4 of 4 , Oct 2, 2008
          • 0 Attachment
            From: "Karen Nadalin" <kznadalin@...>
            > I'm a bit desperate to locate a resource that can help me understand
            > this assignment. I've plowed through a number of reading assignments,
            > searched online to understand "for loop" and I still don't quite get
            > what I' supposed to do. I need a push in the right direction.
            >
            > Task:
            > Start with an array (1, 2, 3, 4, 5) and use a for loop to get the
            > array to be equal to (1, 2, 3, 4, 5, 6, 7, 8). Display the result.
            >
            > If anyone has a resource or helpful tip so I can understand what I'm
            > to do, I thank you.
            > Karen

            Maybe they meant

            my @array = (1, 2, 3, 4, 5);

            for(my $i = 6; $i <= 8; $i++) {
            push @array, $i;
            }

            Jenda
            ===== Jenda@... === http://Jenda.Krynicky.cz =====
            When it comes to wine, women and song, wizards are allowed
            to get drunk and croon as much as they like.
            -- Terry Pratchett in Sourcery
          Your message has been successfully submitted and would be delivered to recipients shortly.