RE: How to check if a set of numbers are in the correct Sequence.

2003-06-13 Thread Bakken, Luke
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; &

Re: How to check if a set of numbers are in the correct Sequence.

2003-06-13 Thread Rob Dixon
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.

RE: How to check if a set of numbers are in the correct Sequence.

2003-06-13 Thread Bakken, Luke
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