harry34 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: Calculation loop (homework?)
by talexb (Chancellor) on Feb 04, 2002 at 14:37 UTC
    This sounds an awful lot like a homework assignment, so instead of answering (probably using something like hashes and eval), let me ask: What have you tried so far?

    More effort, please.

    --t. alex

    "Of course, you realize that this means war." -- Bugs Bunny.

Re: Calculation loop
by BazB (Priest) on Feb 04, 2002 at 14:39 UTC

    Even if this problem isn't homework (this is becoming a tired phrase...), you might benefit from tackling this problem yourself.

    Split the problem into pieces.

    My solution is a little messy, but I'll give you a few hints.

    • Use Super search to look up how to read lines from a file
    • Consider using a conditional loop:
      if (condition) { # do something }
    • Assign the number on the line you've read to a variable (for example: $number)
    • Assign a 0 or 1 to another variable and keep track of whether or not you've divided or not.($divide_p)
    • Figure the rest out.
Re: Calculation loop
by particle (Vicar) on Feb 04, 2002 at 14:47 UTC
    can you provide some code so we know you've given it a go?

    i'll help you with the pseudo-code.

    create variable old, new read first number, save to variable old for each remaining number in list: read number, assign to new, print new / old, assign old = new

    ~Particle