home *** CD-ROM | disk | FTP | other *** search
- # Perl version of cat
- # Usage : cat [-n] file1 file2 ...
- #
-
- $number = 0;
- # Is the first argument a -n ?
- if (substr($ARGV[0], 0, 2) eq "-n")
- {
- $number = 1;
- shift;
- }
-
- # For each file specified.
- foreach $_ (<@ARGV>)
- {
- open(INPUT, $_);
-
- $count = 1;
- while ($line = <INPUT>)
- {
- $line =~ s/ / /g;
- if ($number == 1)
- {
- printf("%4d ", $count++);
- }
- print $line;
- }
- close(INPUT);
- }
-