123 45 -23 56 <-3.45 145 555 112 -12.0 -2.55 >From those lines, is it just the -3.45 and -2.55 that you are after? If so then the following should work.
my @lines = ('123 45 -23 56 <-3.45', '145 555 112 -12.0 -2.55'); foreach (@lines) { /(-?\d*\.?\d+)$/; print "Found $1\n"; } The regex /(-+\d+\.+\d+)$/; breaks down in the following way. () store the value found in the special $1 variable/ -+ Look for 0 or 1 instance of the - sign \d* Look for 0 or more digits \.? Look for 0 or 1 decimal point \d+ Look for 1 or more digits $ match the end of the string, so the match found must appear at the end of the string of data. This is probably where you were going wrong before. HTH John -----Original Message----- From: Nestor Florez [mailto:[EMAIL PROTECTED]] Sent: 04 January 2002 02:26 To: [EMAIL PROTECTED] Subject: HELP - finding a float while reading a file Hi there, I am trying to read a file and find the last numeric value in the line read. example: 123 45 -23 56 <-3.45 145 555 112 -12.0 -2.55 all of the values are separated by a space and I am looking for the last value. I tried $_ = s/[-][0-9].+$/$1/; $number = $1; The problem is that, not aleways I am getting the last value starting at the negative value. Somtime I get the second to last value. Thanks in advance, Nestor :-) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------Confidentiality--------------------------. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]