On 8/25/07, Chris <[EMAIL PROTECTED]> wrote:

>     if (my $start <= $timestamp <= my $stop){

Until Perl 6, you have to break down chain comparisons like this into
separate comparisons, usually joined with 'and':

    if ($start <= $timestamp and $timestamp <= $stop) { ... }

But the real problem is the my() function, which should rarely if ever
appear within a conditional expression. Use my() to declare lexical
variables at the start of their scope. The scope of a lexical variable
is the part of the program in which these names can be used for these
variables. The scope continues until the end of the smallest enclosing
block or file.

In this case, you need to declare your variables outside the scope of
the subroutine, since you don't want them to be available only within
the sub. Ideally, they should be declared in the smallest possible
scope that needs them. I think you want them to be declared near the
start of gather_mtime_between, using the subroutine parameters in the
@_ variable:

  my($start, $stop) = @_; # sub parameter list

That is to say, each invocation of gather_mtime_between would be given
its own $start and $stop values. It can then return closures, which
are subroutines which use those persistant variables from a larger
scope.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to