Subject: | v.1.0.3 Verbose + for loop |
Date: | Mon, 22 Sep 2008 10:48:20 +0200 |
To: | <bug-smart-comments [...] rt.cpan.org> |
From: | Erik Bachmann <e_bachmann [...] hotmail.com> |
Hello Damian
I tested Smart::Comments using this little script:
use Smart::Comments;
### Test 1
my @array;
for (my $i = 0 ; $i < 100 ; $i++) {
push(@array, $i);
}
for (@array) { ### Evaluating |===[%] |
select(undef, undef, undef, 0.01 );
}
### Test 2
for (my $i = 0 ; $i < 100 ; $i++) { ### Evaluating |===[%] |
select(undef, undef, undef, 0.01 );
}
Which I expected would give the same result. But instead I ended up with this:
### Test 1
### Test 2
Evaluating |=============[78] |
The second for loop stops at 78%.
This is what the debugger tells:
00001
00002 use Smart::Comments;
00003
00004 Smart::Comments::_Dump(pref=>q{Test 1:},var=>Smart::Comments::_quiet_eval(q{[Test 1]}));$DB::single = $DB::single = 1
00005 my @array
00006 for (my $i = 0 ; $i < 100 ; $i++)
00007 push(@array, $i)
00008
00009 my $not_first__1;for (my @SmartComments__range__1 = @array) { Smart::Comments::_for_progress(qq{Evaluating |===[%] |}, $not_first__1, \@SmartComments__range__1)
00010 select(undef, undef, undef, 0.01 )
00011
00012 Smart::Comments::_Dump(pref=>q{Test 2:},var=>Smart::Comments::_quiet_eval(q{[Test 2]}));$DB::single = $DB::single = 1
00013 my $not_first__2;for (my $i = 0 ; $i < 100 ; $i++) { Smart::Comments::_while_progress(qq{Evaluating |===[%] |}, \$not_first__2)
00014 select(undef, undef, undef, 0.01 )
00015
The second for loop is interpreted as a "while".
Smart::Comments is a nice feature - but I usually compile my scripts for security reasons before distributing to my serveres. This means that I cannot use the comment switch on the "use" statement.
Instead I inserted a flag:
our $verbose = 1;
and simply makes the called subroutines return if the flag is not set.
This - or something similar - would be nice as a standard feature.
Regards!
{ö} Erik Bachmann
--
Erik Bachmann, Grydehøjvej 62, DK-4000 Roskilde
URL: www.ClicketyClick.dk | www.E-Bachmann.dk
Show quoted text
_________________________________________________________________
Lav det fedeste blink til din Messenger - Klik her
http://www2.messengerplayground.dk/spil