in reply to How can I match between two integer numbers

Unless I've missed something, can't you just use split to get the job done?

while (<DATA>) { my @Data = split ( /\s+/ ); print "Compare $Data[2] and $Data[5].\n"; } __DATA__ 50545 4.393864E+00 .0 50546 9.589456E+00 .0 50547 2.690474E+00 .0 50548 -1.668896E+01 .0 50549 -3.391918E+01 .0 50550 -3.634581E+01 .0 50551 -3.176630E+01 .0 50552 -1.747830E+01 .0 50553 -5.256684E-01 .0 50554 1.135265E+01 .0

This code seems to work fine.

--t. alex
Life is short: get busy!

Update: D'Oh! Sorry -- I thought the objective was to compare the numbers in exponent notation, not the integers before them. Thanks gjb.

Replies are listed 'Best First'.
Re: Re: How can I match between two integer numbers
by gjb (Vicar) on Jan 02, 2003 at 17:28 UTC

    Or, variation on the theme above, but keeping to what was asked (i.e. matching between the integer, not matching the individual real numbers):

    while (<DATA>) { chomp($_); my ($dummy, @Data) = split ( /\s+\d+\s+/ ); print join(", ", @Data), "\n"; } __DATA__ 50545 4.393864E+00 .0 50546 9.589456E+00 .0 50547 2.690474E+00 .0 50548 -1.668896E+01 .0 50549 -3.391918E+01 .0 50550 -3.634581E+01 .0 50551 -3.176630E+01 .0 50552 -1.747830E+01 .0 50553 -5.256684E-01 .0 50554 1.135265E+01 .0

    Hope this helps, -gjb-