Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Perl Array issue.

by tobyink (Abbot)
on May 07, 2012 at 07:19 UTC ( #969198=note: print w/replies, xml ) Need Help??

in reply to Perl Array issue.

You never increment $done (or at least you don't in the incomplete code shown above). Therefore $done is always zero, and while($done==0) will keep looping.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: Perl Array issue.
by Pan20 (Novice) on May 07, 2012 at 15:34 UTC

    Hi tobyink , how can I increment $done ? don't you think that my @timestamp array is causing the infinite loop,because without this piece of code it works, how can I make the array stop at the end of the string, Thanks.

      Let's back up a step: what's the purpose of your inner while loop? Is there a reason you might want to insert some records from your input file multiple times? If not, then you don't need that while loop (or $done or $retry). Just loop through your CSV file record by record as you're doing, and for each record, do whatever processing you need to do on the fields and insert it into your database.

      Aaron B.
      My Woefully Neglected Blog, where I occasionally mention Perl.

      ++ is the increment operator. You can also use = to assign a nonzero value if you like.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://969198]
[stevieb]: glad I have an exceptionally high-quality test regimen for the Pi with...
[stevieb]: ...a diagram of how to set it up. Allows me to not only test my software, but the hardware, side-by-side.

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2018-01-16 22:18 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (192 votes). Check out past polls.