#!/usr/bin/perl -w

#### PS2P-5

#    VERSION: 1 (24 September 2003)
#    PURPOSE: Identifies primes from 2 to specified integer

############## LIBRARIES AND PRAGMAS ################

  use strict;

############# CONSTANTS and VARIABLES ###############

  my $LF = "\n";            # Linefeed
  my $integer;              # integer candidates
  my $last_integer = 1000;  # last integer considered
  my $factor;               # factors tested
  my @primes;               # primes found amongst integers tested

################### MAIN PROGRAM ####################

   INTEGER: for ($integer=2; $integer < $last_integer; $integer=$integer+1) {

      FACTOR: for ($factor=2; $factor <= sqrt($integer); $factor = $factor + 1) {
         if ($integer % $factor == 0) {next INTEGER}
      }
      push @primes, $integer;

   }

   print "@primes";
