#! /usr/bin/perl -w

if( 0 ) {
    @arr = (1, 2, 'Three');
    print "@arr\n";
    $nItems = scalar @arr;
    print "The array contains $nItems\n";
    foreach $item (@arr) {
	print "$item\n";
    }
}

if( 0 ) {
    @arr = (1, 2, 'Three');
    for($i = 0; $i < @arr; $i++) {
	print "Item with index $i = $arr[$i]\n";
    }
}

if( 1 ) {

    print "How many terms do you need in the series\n",
    "1 2 3 4 5 6 7 8 9 ... in order for the sum to be > 50000?\n";
    
    $sum = 0;
    $term = 1;
    while( $sum <= 50000 ) {
	$sum += $term;
	$term++;
    }
    print "I need $term terms which gives me a sum of $sum\n";

}

if( 1 ) {

    print "How many terms do you need in the series\n",
    "1 2 3 4 5 6 7 8 9 ... in order for the sum to be > 50000?\n";
    
    $sum = 0;
    $term = 1;
    until( $sum > 50000 ) {
	$sum += $term;
	$term++;
    }
    print "I need $term terms which gives me a sum of $sum\n";
}
