use strict; $| = 1; # turn off output buffering if ( @ARGV and $ARGV[0] =~ /^\d+$/ and ! -f $ARGV[0] ) { show_sec( @ARGV ); } else { while (<>) # read a line from STDIN (or from a named file) { chomp; show_sec( $_ ); } } sub show_sec { for ( @_ ) { if (/^\d+$/) { my $sec = $_ * 86400; my $s = ( $_ == 1 ) ? '':'s'; print "[$_] day$s = [$sec] seconds\n"; } else { warn "$_ is not a positive integer; I'll ignore that.\n"; } } }