CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
File handeling to make multiple files: help needed urgently


New User

Sep 14, 2011, 3:19 AM

Post #1 of 2 (1528 views)
File handeling to make multiple files: help needed urgently Can't Post

Input is taken from the file given by a user "toplevel.file" having file handler PO. Output of the prog gives "output.file" as an output. Now ,once output file has been made I want to make it as another input file and create another output file till my loop ends.

The following code has been made.

open (PO, "<toplevel.file") or die "check file";
for ($l=0; $l<4; $l++)
open (FO, "+<output.file$l") or die "check file";
if ($l=0)
{ @temp=<PO>;}
if ($l>0)
{ @temp=<FO>;}

and depending on file handler further operations are carried out.



Reply awaited.



Sep 15, 2011, 3:34 AM

Post #2 of 2 (1518 views)
Re: [q1w2e3] File handeling to make multiple files: help needed urgently [In reply to] Can't Post

having file handler PO.

I guess you mean file handle, not file handler. A file handler is something different.

As for your question: To use your output file later on as an input file, you have two options to choose from:

- Close the output file, then reopen it as input file.

- Initially create the output file for "read and write", and use the tell()/seek() functions to reposition the file pointer.

BTW, I suggest that you use a localized variable as a file handle, instead of a global handle, i.e.

open(my $po, ...)

This is not so important in your small example code, but can make things easier when your code gets more complicated.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives