473,408 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Input file question

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);
Jul 19 '05 #1
1 1807
SL_McManus wrote:
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.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ron | last post by:
Hi, I'm still new at Python and have been away from programming for a number of years in general. I apologized in advance if this has been discussed extensively already. Is the input()...
2
by: Sonny | last post by:
Hi experts, I am writing a small code to read input from a file, for example my input file is: X Y Z 26.0 28.0 0.0 32.0 8.0 0.0 My code is:...
2
by: SophistiCat | last post by:
Hi, I am working on a computational program that has to read a number of parameters (~50) from an input file. The program contains a single class hierarchy with about a dozen member-classes or...
3
by: Ben | last post by:
Here's my form: <form name="aForm" method='post'> <input type=file name=file1 onkeypress='KeyPress()'><br> <a id='attachMoreLink' href='javascript:AddFileInput()">Attach More Files </a> <input...
6
by: tshad | last post by:
I have an upload file input as: <input id="MyFile" style="width:300px" type="File" runat="Server"> This works fine, but I find that if my page doesn't pass validation during postback, the page...
5
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file"....
4
by: Petr Vileta | last post by:
Sorry if my question was be here earlier, I'm new here ;-) I have html form where is the tag <input id="x" type="file" name="upload"> and another fields. After submit script on server take some...
2
by: gonzo | last post by:
Say you have a .txt file with a random amount of numbers. Is there a way to initialize an array with that input file of numbers? After telling the program to open the input file, "inputFile," I...
12
by: Tarique | last post by:
I have tried to restrict the no. of columns in a line oriented user input.Can anyone please point out potential flaws in this method? btw.. 1.I have not used dynamic memory allocation because...
14
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In my windows applicationm, i need to excute a batch file. this batch file throws some text and questions to the screen, i need to catch the standard Output, check if it's a question, in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.