root/paper-tape-project/trunk/perl-tools/how-long-is-this-papertape
| Revision 1, 0.5 kB (checked in by sven, 4 years ago) |
|---|
| Line | |
|---|---|
| 1 | #!/usr/bin/perl |
| 2 | # |
| 3 | # kleines (Spaß)programm: Wie lang ist diese Datei als Lochstreifen? |
| 4 | # Benutzung: |
| 5 | # ./programm.pl [datei1] [datei2] [datei3] [usw...] |
| 6 | # |
| 7 | |
| 8 | my $total_l = 0; my $l; |
| 9 | foreach (@ARGV) { |
| 10 | $l = (stat)[7]; |
| 11 | print "$_: $l bytes = ".bytes2cm($l)." cm\n"; |
| 12 | $total_l += $l; |
| 13 | } |
| 14 | print "total: $total_l bytes = ".bytes2cm($total_l)." cm\n" |
| 15 | unless($l eq $total_l); # nur ein Argument. |
| 16 | |
| 17 | sub bytes2cm { |
| 18 | my $bytes = shift; |
| 19 | # inch = $bytes/10; |
| 20 | # centimeter = inch / 2.54 |
| 21 | my $cm = ($bytes / 10) * 2.54; |
| 22 | } |
Note: See TracBrowser
for help on using the browser.
Powered by
Expect where otherwise noted, content on this site is licensed under a