in reply to Count the number of lines in a file

You can get the size of a file with -s but that's not the same as the number of characters unless the file uses an encoding that is always one byte per character.
#!/bin/perl use strict; use warnings; my $chars = 0; my $lines = 0; while (<>) { $chars += length; $lines ++; } print "$chars $lines\n";
You can call this script with the files as standard input and standard output.

If you want to open the files within the Perl script instead use the open() function.