This code reads a file. DIN is a filehandle, its name can be chosen arbitrarily. This code is a little "older" style Perl, a more "modern" way to write the same thing would be:
open my $din, '<', $file_name or die "failed to open $file_name: $!";
To write to a file, you'd use ">" instead of "<", and then use print to write to the file, as in print $din "some text\n"; Some quick googling brings up this nice tutorial: http://perlmaven.com/writing-to-files-with-perl , and the documentation for open explains that function in detail.
There are several good books that will help greatly in learning Perl, see for example the "Learning Perl" series here: http://shop.oreilly.com/category/browse-subjects/programming/perl.do . If you don't want to spend any money yet, chromatic's "Modern Perl" is available online for free: http://onyxneon.com/books/modern_perl/ |