Content area
There is no doubt that Perl is excellent at gluing together outside-world programs and data, but it is also good at the pure programming problems you might find in a beginning computer-science course. It is demonstrated that Perl is good for both theoretical and practical uses.
Full text
There's no doubt that Perl is excellent at gluing together outside-world programs and data, but it is also good at the pure programming problems you might find in a beginning computer-science course. For example, let's take a look at that common task in your typical first-year computer course-finding prime numbers.
As you may recall from your early math years, a prime number is any integer greater than 1 that is divisible by only 1 and itself. Let's generate some prime numbers using a very direct translation of this specification:
The outer loop is named GUESS, so that we can skip forward with respect to this loop even from within the inner loop. The variable $guess is my try at each prime number. I'm establishing a lexical local variable for this loop, initializing it to 2, and incrementing it by 1 until it hits 10,000.
If you're curious about knowing a lot more about prime numbers (perhaps more than you wanted to know), http://www.utm.edu/research/primes/ seems to be a great resource.
So, as you can now see, a first-year computer-science problem can be solved handily by Perl, demonstrating that Perl is good for both theoretical and practical uses. _
Copyright Miller Freeman Inc. Jun 1999