open

A Perl “read file into array” example

Perl read file FAQ: How can I read a file into an array in Perl (Or, Can you share a Perl read file into array example?)

One of the really cool things about Perl is that it's super-easy to read a file into a Perl array. This is really handy any time you need to read a file for any reason.

A Perl read file into array example

If you want to read a file into a Perl array, you actually only need one line of code, like this:

Perl: How to test if a file exists

Perl file exists FAQ: How can I perform a test to see if a file exists with Perl?

You can test to see if a file exists with the Perl "-e" file operator.

A Perl file exists example

Here's a short test/example:

How to open and read a text file in Java (FileReader, BufferedReader)

Java File I/O FAQ: How do I open a file and read text from it using Java? (Also written as, “How do I use the Java BufferedReader and FileReader classes to read from a text file?”)

Solution: Here’s a method taken from a Java class I wrote that shows how to open and read a file using the Java FileReader class. This uses the most recent Java syntax and classes.

Perl files example - How to open and read data files with Perl

Perl files FAQ: How do I open and read files in Perl?

This article demonstrates how to open and read files in Perl. As you'll see, the creators of Perl thought this was a fundamental activity, and they've made it as easy as possible. (That's one of the things I really like about Perl - many of the routine, daily programming tasks have been made very easy with this language.) If you've used other "structured" languages, such as C or FORTRAN, you'll appreciate how easy it is to open a file and create a loop to read data from the file.

Perl - How to read from a named pipe (fifo)

Perl FAQ: How can I write a Perl script to read from a named pipe (FIFO file)?

Here’s some code from a Perl program where I open up a named pipe (a FIFO file), then read data from that file until the end of time ... or at least until someone kills this program.