Perl read/write File

This is a simple example how to write into a File with Perl, and then read from it.At first we write the numbers from 1 to 6 into the file, in the second we read from the file and print it on the screen, if you don’t want the “\n” at the end use the function chomp.

If you open a File for read use ‘<‘, for write ‘>’ and for append ‘>>’.

Result looks like:

you could check if a handler is open with this Perl handler function.

2 thoughts on “Perl read/write File”

Leave a Reply

Your email address will not be published.

4 × four =