Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Flip-flop reset?

by sgifford (Prior)
on Aug 30, 2006 at 01:37 UTC ( [id://570288]=note: print w/replies, xml ) Need Help??


in reply to Flip-flop reset?

Interesting question. I'm not sure of the answer, but a kludgey workaround is to always make sure you start with something that will cause the flip-flop to reset:
foreach ( "\n",@arr ) { ...

Replies are listed 'Best First'.
Re^2: Flip-flop reset?
by swkronenfeld (Hermit) on Aug 30, 2006 at 14:47 UTC
    Nice idea sgifford. I think that what I may do is actually put the newline at the end
    foreach (@arr, "\n") {
    They should work identically, as far as I can tell, but I can verify that the operator flops before leaving the subroutine now. This should work for both cases of input as I stated above.

    Thanks for everyone's input.
      That will only work if you are certain nothing in your for loop will bail out early, including something throwing an exception that's caught by a caller of your sub. Putting the dummy "\n" at the beginning of the loop is safer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://570288]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-03-29 06:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found