May 032010
 

I’m not sure how a Perl code snippet will react in a CMS posting so I’ve commented it out; if you have use for this simple script remove the “#” comment characters.  The code could be named anything, I call it readme.pl and it is run from the command prompt as ‘perl readme.pl filename‘. The file utilizes the default file handle within the “while()” to open the file referred to by @ARGV (a special variable) and two common special variables “$.” and “$_” for line numbers and default input respectively.

#!/usr/bin/perl
#
# use strict;
# use warnings;
#
# main(@ARGV);
#
# sub main
# {
# while() {# using the special file handle to read lines from the command line
# print “$. $_”;
#  }
#}

Sorry, the comment form is closed at this time.