Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.3 Reading, Writing and Filehandles

open FILEHANDLENAME "filename";
In earlier chapters we looked at how to read and write to STDIN and STDOUT respectively. The mechanism for working with your own filehandles is no different. If we wanted to read the contents of file called .mydata. and display the contents to STDOUT we could do so as follows:
open MYDATA, "datafile"; while (<MYDATA>) { print; }
Similarly we use the print and printf commands that we previously used to write to STDOUT to write to our filehandle:
Open OUTFILE "<outfile"; printf OUTFILE "This chapter %d of Picking Up Perl.\n", 10; print OUTFILE "The End\n"
By default the print operators will output to STDOUT unless a filehandle is specified. The default filehandle can be changed using the .select. operator:
Select OUTFILE;



 
 
  Published under the terms of the GNU General Public License Design by Interspire