On Thu, Jan 1, 2009 at 12:16, Collaborate <tolg...@yahoo.com> wrote: > After wiriting the output of a Perl program to a text file, I'd like > to immediately open (display the contents of) that text file from > within the code so I can see what's in the file. I am wondering if > there is a simple way to accomlish this. Thanks.
Well, the easiest way is to print only to the screen and use a utility like tee to put the output into a file: ./perl_script.pl | tee output.txt | less The next best thing is to do what tee is doing in your code (write to both STDOUT and your filehandle): print $line_of_data; print $filehandle $line_of_data; But if you are dead set on printing the file after it is written, just open and print it: open my $filehandle, "<", $filename or die "could not open $filename: $!"; print while <$filehandle>; If the file is long and you want to do paging, well, that really isn't Perl's job. Use whatever pager your OS provides (more, pg, less, etc.). In general, they offer more features than you would want to code yourself and they have the benefit of already having been written and debugged. -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/