Input file question

S

SL_McManus

Hi;

What I am trying to do is to read the input file and and pull a
10 byte section of lines 4 - 6 to a variable. I would take these in
order and drop the numbers into $x, $y, & $z. I'm not sure if I have
something mislabled or my logic is incorrect. I commented out two
sections to try to isolate one variable. Any thoughts are welcomed.




Input File (6 lines long)

Initial Check file for auditing


Initial Input File TC 849
Greater than 9.99 File TC 847
Less than/equal to 9.99 File TC 2




$linecount = 6;
$lineread=0;
$value=1;
$count=0;

# start output
my @lines = ( );
open(AUDTFILE, '>'.$audtfile) || die "Unable to open $audtfile $!\n";
binmode(AUDTFILE);
for $line (@lines) {
# split it up per-line
for $linecount (split(/\r?\n/, $line)) {
# this is the line we care about
if ($linecount == 4) {
# substr($line, [col to start], [number of char's to go])
my $x = substr($line, 37, 10);
}
#else ($linecount == 5) {
# my $y = substr($line, 37, 10);
# }
#else ($linecount == 6) {
# my $z = substr($line, 37, 10);
# }
}
}

close(AUDTFILE);
 
G

Gunnar Hjalmarsson

SL_McManus said:
What I am trying to do is to read the input file and and pull a 10
byte section of lines 4 - 6 to a variable. I would take these in
order and drop the numbers into $x, $y, & $z. I'm not sure if I
have something mislabled or my logic is incorrect.

Most of it seems to be incorrect.

http://learn.perl.org/

Newsgroups do not replace own serious efforts.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top