in reply to Editing a text file without reading it into an array

Welcome, brother whiteperl :-)

Is there a way to edit text files without reading the entire file into an array?

Well, it's a matter of context. As you will learn reading the fine documents other monks pointed you to, reading from a filehandle could be done in list context, e.g.: my @file_contents = <MYFILE>;; or in scalar context, e.g.: my $line = <MYFILE>.

When you read from a file in list context, you get all the file as a list (i.e.: something you could assign to an array or give as argument to a function that requires a list, like print). Assigning to an array slurps all the file into the array, one line per element. OK, you already know this.

When you read in scalar context, you get next line from the file. The concept of "next line" should be quite clear: if you open a file and immediately after you do a my $firstline = <MYFILE> ;, $firstline gets the first line. Next <MYFILE> "call" in scalar context will get the second line and so on.

Whenever possible, it is better not to read a whole file in memory at once since it could eat a lot of memory if the file is big, and it could take a lot of time, too. Reading step by step, like while (my $line = <MYFILE>) { do_something_with($line) } is often better.

Ciao!
--bronto

Update: of course, do_something_with($line) could end up in messing up $line and printing out to another filehandle, which is what I understand you call editing :-)

# Another Perl edition of a song:
# The End, by The Beatles
END {
  $you->take($love) eq $you->made($love) ;
}