Re: how to do something

From: James Willmore (jwillmore_at_remove.adelphia.net)
Date: 10/25/03


Date: Sat, 25 Oct 2003 17:50:25 GMT

On Sat, 25 Oct 2003 18:39:59 +0100
"Lex" <nospam@peng.nl> wrote:
> I've got two subroutines, one is saying 'do the other x times'. The
> other is checking records from a database and prints the x latest
> records. However, when a record matches something, it should be
> skipped. It all works, however, what happens is that the results are
> x - 1. So in the example underneath I normally get 3 results, except
> when $vergelijker = jep, than the I only get 2 results, although I'd
> prefer 3. I tried this but it doesn't work:
>
> subroutine 1:
>
> my $i = 2;

Where is ^^^ this line being declared? Inside subroutine 1 or
globally? If it's inside subroutine 1, then that's where I _think_
you're issue is - the variable's scope (or where it's life exists).
If $i is supposed to be accessed in _both_ subroutines, then declare
it _outside_ of the subroutines (aka globally).

Or did I miss what you were after?

HTH

-- 
Jim
Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.
a fortune quote ...
Hand, n.:  A singular instrument worn at the end of a human arm
<and commonly thrust into somebody's pocket.   -- Ambrose Bierce,
"The Devil's Dictionary" 


Relevant Pages

  • how to do something
    ... I've got two subroutines, one is saying 'do the other x times'. ... checking records from a database and prints the x latest records. ... underneath I normally get 3 results, except when $vergelijker = jep, than ...
    (comp.lang.perl.misc)
  • Re: Beginning beginner needing references help
    ... > hard way in an effort to learn more core perl. ... > Now the list of states also includes the counties (fetched ... >> both within and outside subroutines. ... >> You can either do what you've done above, and simply declare ...
    (perl.beginners)
  • Re: Powerpoint 2003 VBA subroutine
    ... If you use Dim in a module outside the Sub's then those variables are ... If you declare variables as Public they are available to all modules. ... I had declared my variables within specific subroutines. ... variable within sub 1, I blocked the use of the variable to subs 2,3. ...
    (microsoft.public.powerpoint)
  • Re: Understanding Perl script functionality
    ... You're missing 2 very important pragmas that should be in every script ... # forces you to declare your vars prior to their use. ... mod_perl is a linking/binding of the perl interpreter with the ... scripts as compiled subroutines in separate packages. ...
    (perl.beginners)
  • Re: Debuging problems!?
    ... Contrary to what another poster said, most compilers do not do run-time ... -|integer number carrying into my subroutines become to large. ... -|For example, I declare ... we also use many COMMON blocks. ...
    (comp.lang.fortran)