Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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'
Comment on Re: Perl Array issue.
Select or Download Code
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]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2016-05-05 00:54 GMT
Find Nodes?
    Voting Booth?