Display the (in)famous LOST television series numbers on the command line. Perl one-liner to exec with ActiveState PERL on Windows.
perl -e "$|=1;@lostNumbers=('4','8', '15', '16', '23', '42'); while (1) { print ' ' x (rand(35) + 1), ($lostNumbers[int rand @lostNumbers]) }"
As a script, lostNumbers.pl, you can get a bit fancier with different subroutines...
perl -e "$|=1;@lostNumbers=('4','8', '15', '16', '23', '42'); while (1) { print ' ' x (rand(35) + 1), ($lostNumbers[int rand @lostNumbers]) }"
As a script, lostNumbers.pl, you can get a bit fancier with different subroutines...
#!/usr/bin/perl -w
use warnings;
use strict;
#&lostNumRandFast;
#&lostNumRand;
#&lostNumRandGapsFast;
&lostNumRandGaps;
#&lostNumRandStart;
sub lostNumRandFast {
$| = 1;
my @lostNumbers=('4', '8', '15', '16', '23', '42');
my $iterations=65535;
while ($iterations--) {
print ' ' x (rand(35) + 1);
print ($lostNumbers[int rand @lostNumbers] );
}
}
sub lostNumRand {
$| = 1;
my @lostNumbers=('4', '8', '15', '16', '23', '42');
my $iterations=65535;
while ($iterations--) {
print ' ' x (rand(35) + 1);
print ($lostNumbers[int rand @lostNumbers] );
sleep (int rand 4);
}
}
sub lostNumRandGapsFast {
$| = 1;
my @lostNumbers=('4', '8', '15', '16', '23', '42');
my $iterations=65535;
while ($iterations--) {
my $i = 0;
while ($i++<=$#lostNumbers) {
print ' ' x (rand(35) + 1);
print ($lostNumbers[($i-1)] );
}
}
}
sub lostNumRandGaps {
$| = 1;
my @lostNumbers=('4', '8', '15', '16', '23', '42');
my $iterations=65535;
while ($iterations--) {
my $i = 0;
while ($i++<=$#lostNumbers) {
print ' ' x (rand(35) + 1);
print ($lostNumbers[($i-1)] );
sleep (int rand 4);
}
}
}
sub lostNumRandStart {
$| = 1;
my @lostNumbers=('4', '8', '15', '16', '23', '42');
my $iterations=65535;
while ($iterations--) {
my $i = rand($#lostNumbers) + 1;
while ($i++<=$#lostNumbers) {
print ' ' x (rand(35) + 1);
print ($lostNumbers[int rand @lostNumbers] );
sleep (int rand 4);
}
}
}
Be sure to include "$|=1" for autoflushing on the current output file handle (STDOUT). Maybe later I will write up one for the Fibonacci sequence. That would be neat. Thanks to Command Line Fu post "Binary Digits Matrix Effect" for the initial idea. As you can see below, the irregular spacing make the numbers appear angled slightly. A nice optical illusion.
Ref:
Comments