Skip to content

Instantly share code, notes, and snippets.

@thunderpoot
Last active November 1, 2020 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thunderpoot/73ad56b96d5c5b5544fdee528bcbd801 to your computer and use it in GitHub Desktop.
Save thunderpoot/73ad56b96d5c5b5544fdee528bcbd801 to your computer and use it in GitHub Desktop.
In response to some Python someone posted somewhere
#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes 'usleep';
$|++; # force auto-flush (see perldoc perlvar)
my $distance = 1 + int(rand(49));
my @stones = ("_","-");
print( "\e[?25l" ); # hide cursor
for ( my $i = 1; $i < $distance; $i++ )
{
print( "\e[" . sprintf ( $i * 2 + 1 ) . "D " );
print( " " x $i );
print( $stones[ rand @stones ] );
usleep(90000);
}
print( "\e[D'splash!'\n" );
print( "\%You scored: $distance\n" );
print( "\e[?25h" ); # show cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment