Created
June 6, 2017 22:10
-
-
Save chrisdavidmiles/9fd35779517ac601594aaf593a30dde2 to your computer and use it in GitHub Desktop.
Rolling Text in Perl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use 5.010; | |
use Time::HiRes qw (sleep); | |
sub rand_letter() { | |
@letters=(A..Z,a..z," ",".",","); | |
return $letters[rand @letters]; | |
} | |
my $final_form = "Hello world"; | |
my @final_form = split //, $final_form; | |
my @done; | |
foreach (@final_form){ | |
my $letter=rand_letter(); | |
my $to_match = $_; | |
say $to_match; | |
while ($letter ne $to_match){ | |
$letter=rand_letter(); | |
print "\033[2J"; #clear the screen | |
print "\033[0;0H"; | |
print @done; | |
say $letter; | |
sleep(.02); | |
} | |
push @done, $letter; | |
$i++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment