On Sun, Jan 4, 2009 at 22:36, Mr. Shawn H. Corey <shawnhco...@magma.ca> wrote:
snip
> my $Backup_Count = 0;
>
> sub back_and_print {
>  my $text = shift @_;  # no tabs, no newlines!
>
>  print "\b" x $Backup_Count;
>  print " " x $Backup_Count;
>  print "\b" x $Backup_Count;
>  $Backup_Count = length $text;
>  print $text;
> }
snip

Since $Backup_Count is acting as a static variable (in the ANSI C
sense) for back_and_print it would be a good idea to limit the access
to it to subroutine:

{
    my $Backup_Count = 0;

    sub back_and_print {
        my $text = shift @_;  # no tabs, no newlines!

        print "\b" x $Backup_Count,
            " "    x $Backup_Count,
            "\b"   x $Backup_Count,
            $text;
        $Backup_Count = length $text;
    }
}

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to