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 number is less than or equal to the current. Luke > -----Original Message----- > From: James Parsons [mailto:[EMAIL PROTECTED] > Sent: Friday, June 13, 2003 1:25 PM > To: [EMAIL PROTECTED] > Subject: How to check if a set of numbers are in the correct Sequence. > > > 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. > > > Any help would be great > > James Parsons. > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]