There *has* to be an elegant way to do this in Expect...

I have a command that returns lines of numbers. Like:

prompt% mycommand --loop=5
9 4956 4951 4951 4956
9 4960 4951 4951 4956
9 4956 4951 4951 4956
9 4956 4951 4951 4956
9 4956 4951 4951 4956
prompt%

All numbers must be inside a given interval (eg. 4900-5000 in the case above). If they are not I must report which column that has the number outside the interval (column 0 above).

I could start a lot of bash and/or C programming, but I would rather keep it all in the Expect script that I am using to invoke the command from anyway.

Any suggestions?