Thanks all for your input and rapid response. This is just what I was looking for--even more than I anticipated. I find that Tye's solution returns what I need when run against my test data. More testing is in order and I'll probably work a little with the other suggestions just to broaden my horizons and explore TIMTOWTDI. Here's the code I'm working from now:
use strict;
my $outfile = "\\NewCodes.txt";
my $infile = "C:\\TestTBL.txt";
# $filename is already defined
open (LOGFILE, ">$outfile") or die "Can't create logfile: $!";
open NAMES, $infile or die "Can't open input datafile: $!\n";
while( <NAMES> ) {
while( /(\d+(?:\.\d+)?)/g ) {
if( $1 ne '305.1'
&& 290.0 <= $1 && $1 <= 314.0 ) {
print LOGFILE;
last;
}
}
}
___DATA
4106693","01/01/00","305.1","473.9","465.8",,,,,,,
"SP","000154106774","01/01/00","511.0","305.1",,,,,,,,
"SP","000154107231","01/01/00","305.1","490","786.50",,,,,,,
"SP","000154107398","01/01/00","558.9","305.1",,,,,,,,
"SP","000154108114","01/02/00","305.1","789.00","792.1",,,,,,,
"MCD","000154108661","01/03/00","305.1","922.31","E960.0",,,,,,,
"SP","000154110313","01/03/00","305.1","784.0","780.4",,,,,,,
"SP","000154111573","01/03/00","493.91","305.1",,,,,,,,
"MCD","000154111581","01/03/00","599.0","305.1","V14.0",,,,,,,
"MCD","000154115056","01/04/00","789.00","305.1",,,,,,,,
"SP","000154122133","01/07/00","786.50","305.1",,,,,,,,
"MCD","000154125507","01/08/00","305.1","789.00","412",,,,,,,
"SP","000154125736","01/08/00","305.1","E849.5","847.0","847.9","924.8
+","E812.0",,,,
"SP","000154126007","01/08/00","490","305.1",,,,,,,,
"MCD","000154126147","01/08/00","305.1","729.1","346.90",,,,,,,
"MCD","000154126775","01/09/00","305.1","525.8","V45.89",,,,,,,
"MCD","000154127127","01/09/00","305.1","648.93","346.90",,,,,,,
"SP","000154128875","01/10/00","873.63","305.1",,,,,,,,
"SP","000154129243","01/10/00","789.01","305.1",,,,,,,,
"SP","000154130535","01/10/00","729.5","305.1",,,,,,,,
"MCD","000154107771","01/02/00","301.9","780.39",,,,,,,,
"MCD","000154115773","01/05/00","802.0","910.0","E960.0","E849.9","250
+.01","311","758.7",,,
"MCD","000154118241","01/05/00","787.03","295.70","737.30",,,,,,,
"MCD","000154125621","01/08/00","295.70","714.0",,,,,,,,
"MCD","000154125957","01/08/00","812.20","E885","E849.9","309.81",,,,,
+,
"MCD","000154127101","01/09/00","310.1","305.1","E869.4","E849.0",,,,,
+,
"MCD","000154127160","01/09/00","295.90",,,,,,,,,
"MCD","000154130519","01/10/00","723.4","847.0","784.0","E884.3","E849
+.9","907.2","344.1","E929.8","305.1","V44.3"
"MCD","000154131701","01/11/00","300.4",,,,,,,,,
"MCD","000154134085","01/11/00","298.9","305.1",,,,,,,,
"MCD","000154141162","01/13/00","558.9","493.90","296.7",,,,,,,
"MCD","000154141308","01/13/00","784.0","300.01",,,,,,,,
"MCD","000154146431","01/16/00","312.9","536.9",,,,,,,,
"MCD","000154152644","01/18/00","313.81",,,,,,,,,
"MCD","000154154507","01/18/00","298.8","305.1",,,,,,,,
"MCD","000154158766","01/20/00","842.00","E826.1","E849.9","314.00",,,
+,,,
"MCD","000154159631","01/20/00","303.90","305.1",,,,,,,,
"MCD","000154161007","01/20/00","313.81","311",,,,,,,,
"MCD","000154161589","01/20/00","786.50","300.00",,,,,,,,
"MCD","000154165410","01/22/00","305.00",,,,,,,,,
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.