From: Bakken, Luke
> Sent: Friday, June 13, 2003 1:52 PM
> To: James Parsons
> Cc: [EMAIL PROTECTED]
> Subject: RE: How to check if a set of numbers are in the
> correct Sequence.
>
>
> use strict;
>
> my $prev;
> while (<>)
> {
> chomp;
&
James Parsons wrote:
> Hi all
>
> Since I'm new to perl, I'm not sure how to tackle this type of problem
>
> a. I have file with the following in it
> 100
> 101
> 102
> 103
>
> b. How would check if these numbers are in correct sequence
> c And they are not sequence kick out an error message.
use strict;
my $prev;
while (<>)
{
chomp;
die "not a number" unless /^\d+$/;
die "out of order" if $_ <= $prev;
$prev = $_;
}
Usage:
$ perl numchecker inputfile
Let me know if this works OK, it's untested. It should die on a
non-integer input, or if the previous