I would agree, except that rearranging subroutines and variable
declarations in some automated way seems to be a more difficult (and
potentially buggier) task.

--Chris

On Wed, 16 Aug 2000, Douglas Wilson wrote:
> 
> That gives me a 'Variable "$counter" may be unavailable at ./tst2 line 17.'
> warning. And its sort of obfuscated (to me, anyway). I'd probably do it this
> way:
> 
> #!/usr/local/bin/perl -w
> 
> use strict;
> 
> #!/usr/bin/perl -w
> use strict;
> 
> for (1..3){
>     print "run: [time $_]\n";
>     run();
> }
> 
> {
>  my $counter;
> 
>  sub run {
>     $counter = 0;
> 
>     print $counter,"\n";
> 
>     increment_counter();
>     increment_counter();
> 
>  }
>  sub increment_counter {
>        $counter++;
>        print "Counter is equal to $counter !\n";
>  }
> }
> 

Reply via email to