Skip to content

Instantly share code, notes, and snippets.

@chrisdavidmiles
Created June 6, 2017 22:10
Show Gist options
  • Save chrisdavidmiles/9fd35779517ac601594aaf593a30dde2 to your computer and use it in GitHub Desktop.
Save chrisdavidmiles/9fd35779517ac601594aaf593a30dde2 to your computer and use it in GitHub Desktop.
Rolling Text in Perl
#!/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