Here is a simple program. Do not just use it, though. If
you want to write a Perl program, it's best to learn Perl.
#!/usr/bin/perl
$filename = $ARGV[0]; # filename passed on commandline
$size = (-s $filename) * 8 / 128000 / 60;
($min,$sec) = (int($size/60), $size % 60);
printf "$filename is %d:%02d long\n", $min, $sec;
How does it work? Look in 'perlfunc' for the -s file test.
Look at 'perlop' if you need help with the math operators.
Look at 'perldoc -f printf' and 'perldoc -f sprintf' to see
how printf works in formatting your time output.
japhy
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.