This should work. I've used an array to simulate your text files. The first regex (as you already had) matches the lines without a - sign. I've modified your second regex to look for the - sign, thus it picks up negative values only.
@array = ("30000034364717283459322a-15.32zM 042001H", "30000045434551648534245a243.56zM 040532H", "30000053232540927543293a-2.45zM 040332H"); foreach (@array) { print "Positive $_\n" if /a([\d.]+)z/; print "Negative $_\n" if /a-([\d.]+)z/; } HTH John -----Original Message----- From: Stuart Clark [mailto:[EMAIL PROTECTED]] Sent: 05 February 2002 11:25 To: Perl List Subject: distinguishing positive and negative values Hi, How do I distinguish between positive and negative values. This is part of a merchant batch script. The values are between the "a" and "z" I want to make the refunds (negative values) go to one file And the sales (positive values) got to another Regards Stuart Clark # start of file test 30000034364717283459322a-15.32zM 042001H 30000045434551648534245a243.56zM 040532H 30000053232540927543293a-2.45zM 040332H # end of file test open (IN,"test") || die "Could not open the test file\n"; open (OUT,">output_positive") || die "Error could not create the output file\n"; open (OUT2,">output_negative") || die "Error could not create the output file\n"; while (<IN>) { print OUT if /a([\d.]+)z/; # this bit needs to determine the positive values print OUT2 if /a([\d.]+)z/; # this bit needs to determine the negative values } close(IN) || die "Error cannot close test file\n"; close(OUT) || die "Error cannot close output file\n"; close(OUT2) || die "Error cannot close output2 file\n"; # output_positive file must look like this 30000045434551648534245a243.56zM 040532H # output_negative file must look like this 30000034364717283459322a-15.32zM 042001H 30000053232540927543293a-2.45zM 040332H --------------------------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]