The problem with using for and while loops in this, how does it go through
the array elements?  You must use foreach instead.  And even if in some way
you did make it go through the element, at any time while meets a false
value it will exit loop.

Ilya Sterin

-----Original Message-----
From: Bruce W. Hoylman [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 16, 2001 12:40 PM
To: Xiaoxia Dong
Cc: DBI User List
Subject: Re: pass array into subroutine


>>>>> "Xiaoxia" == Xiaoxia Dong <[EMAIL PROTECTED]> writes:

    Xiaoxia> I passes array to one of the subroutine in the main perl
    Xiaoxia> file.

Although this is not a DBI question ... I'll take care of this problem
on the condition that you then refer to proper perl-specific references
for similar questions in the future.  There are zillions of them.

That said:

Not knowing the full scope of your code, I can only surmise your problem
lies in the way you pass @ARGV and the way you return %start.

Pass the array to your sub as a reference, then use it accordingly.
Also, return %start as a reference as well.  Something like this:

     my $start = initStart(\@ARGV);

     sub initStart {
         my ($args) = shift;
         my %start;

         for (@{$args}) {
               do something ...
         }

         return \%start;
    }

Also, remember to always use '-w' and 'use strict;'.  Many problems,
including the one depicted in your question, are pointed out beforehand.

HTHYO.

Peace.

Reply via email to