User Profile

Collapse

Profile Sidebar

Collapse
aplata
aplata
Last Activity: Oct 22 '08, 04:20 AM
Joined: Mar 28 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • aplata
    started a topic Newbie trying to understand nested loops
    in Perl

    Newbie trying to understand nested loops

    I am trying to understand the following code:

    [code=perl] my @arr1=(5,3,2,1, 4);
    my $i=0;
    my $j=0;
    $tmpnum
    for($i=0;$i<@ar r1;$i++) {
    for($j=0;$j<@ar r1;$j++) {
    if($arr1[$i]<$arr1[$j]) {
    $tmpnum=$arr1[$i];
    $arr1[$i]=$arr1[$j]
    $arr1[$j]=$tmpnum;
    };
    };
    };


    foreach(@arr1) {
    print $_...
    See more | Go to post
    Last edited by eWish; Apr 12 '08, 06:23 PM. Reason: Please use code tags

  • aplata
    started a topic Data Manipulation with pop, push, and shift.
    in Perl

    Data Manipulation with pop, push, and shift.

    My instructor has asked me to use the pop, shift, and push functions to write a script that sufficiently "shuffles" a simulated deck of cards before printing the top five cards.

    I came up with the following code but the problem I am having is that I can't seem to shuffle by just using pop, push, and shift. I think the problem for me is trying to understand what constitutes a shuffle because there are many different ways to...
    See more | Go to post
    Last edited by eWish; Mar 28 '08, 02:03 PM. Reason: Please use code tags
No activity results to display
Show More
Working...