473,385 Members | 1,673 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,385 software developers and data experts.

how to controll end of file..

fetaelin
Hi..
I need to read from File1 and File2, and write the first row in file1 + first row in file2 in file3.
if file1 ends before file2, then the program is finnished,
if file2 ends before file1 then it should begin from the beginning untill file 1 ends,
the code I have now is not complete. can you please help me to finnish it ?
thanx.
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2. open(file1, "SA2007");
  3. open(file2, "INTJ2005");
  4. open(file3, ">INTJ2006.del");
  5. while (!(eof(file1)) {
  6.     if((eof(file2)){
  7.         #go to begining of file (how to do that ? 
  8.     }
  9.     else{
  10.         # copy first row of file1 > $fr1
  11.         # copy first row of file2 > $fr2
  12.         # print "$fr1:$fr2" > file3
  13.     }
  14. }
  15.  
  16. close file1;
  17. close file2;
  18. close file3;
  19.  
  20.  
Sep 25 '07 #1
2 2272
mehj123
55
I guess you can use seek FILEHANDLE,POSITION,WHENCE , where you can give WHENCE as SEEK_SET and POSITION as 0. I hope it works..
Sep 25 '07 #2
numberwhun
3,509 Expert Mod 2GB
Hi..
I need to read from File1 and File2, and write the first row in file1 + first row in file2 in file3.
if file1 ends before file2, then the program is finnished,
if file2 ends before file1 then it should begin from the beginning untill file 1 ends,
the code I have now is not complete. can you please help me to finnish it ?
thanx.
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2. open(file1, "SA2007");
  3. open(file2, "INTJ2005");
  4. open(file3, ">INTJ2006.del");
  5. while (!(eof(file1)) {
  6.     if((eof(file2)){
  7.         #go to begining of file (how to do that ? 
  8.     }
  9.     else{
  10.         # copy first row of file1 > $fr1
  11.         # copy first row of file2 > $fr2
  12.         # print "$fr1:$fr2" > file3
  13.     }
  14. }
  15.  
  16. close file1;
  17. close file2;
  18. close file3;
  19.  
  20.  
I have a question. Is this school work? It sounds like it the way it is worded. I ask because it is the policy here on TSDN that we cannot do you homework for you, but can point you in the right direction if you get stuck.

I just needed to let you know that.

Regards,

Jeff
Sep 25 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Michael ALbanese | last post by:
I am developing a telephone directory for my company. I have Fist Name, Last Name, Department and Phone Number as fields. A user can search by entering data into any one, or combination of these...
1
by: Michael Albanese | last post by:
I am developing an application to handle my compay's OSHA reporting requirements. Some of the input criteria are technical and narowly defined, so I was trying to prvide what i call "Context...
5
by: Stampede | last post by:
I browsed the web and found a GUI Controll on a ScreenShot. As the software which uses this controll is written as an Add-In for MS Outlook I think this Controll has to be with the Visual Studio. ...
6
by: KS | last post by:
Is it possible to make the title attribute, which shows a text inside a postit, for a html tag get displayed forever when the coursor is over the html tag. I want the postit to be displayed until...
0
by: Danke | last post by:
I want than only few users are able to use a certain controll (tab) in a form. Is that possible in the security system we have in Access 97 or do I have to program everything in VBA. Helge...
2
by: Brendan zerofor0je | last post by:
Hello, I've written a small reverse-telnet client that connects to a server that handles all the clients. the reverse telnet node ( whitch i will refer to as rtn from now on) works by opening...
0
by: authorking | last post by:
How could I add data rows into a datagrid controll so that I can edit my data in the data rows.
1
by: authorking | last post by:
How could I add data rows into a datagrid controll so that I can edit my data in the data rows.
1
by: ajishapj | last post by:
hii guys i am ajish i am having a problem with my panel controll in vb.net actually i am creating a panel user controll with out a scroll bars(auto scrolling set to false) ,and i have to...
8
malav123
by: malav123 | last post by:
Hi, I am using Tab container Controll of ajax... but my problem is that when i put the tab container in "update pannel" the style of tab container tottly gets changed.. and if i...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.