Isaac's Perl Spinner

my $cur_key = 0;
sub spinner() {
    my @chars = ("-", "\\", "|", "/");
    my $backsp = "\b";

    my $spinner_lag = $_[0] if $_[0];
    if ($cur_key == @chars) {
        $cur_key = 0;
    }

    if ($spinner_lag) {
        my $i;
        if ($i == $spinner_lag) {
            print $backsp . $chars[$cur_key];
            $i = 1;
        }
        else { $i++; }
    }
    else { print $backsp . $chars[$cur_key]; }
    $cur_key++;
}


Note: Replies will be formatted with PHP Markdown Extra syntax.

Name: Email (Not Required):
 
Logged IP: 3.22.27.24
To prevent spam please submit by clicking the kitten: