http://www.perlmonks.org?node_id=231096

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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Perl Paradigm
by dragonchild (Archbishop) on Jan 29, 2003 at 21:20 UTC
    I'm not even sure what you're doing. There's a few issues with the snippets you posted:
    1. In the while, you treat $entry as a number. Then, you treat it as a subroutine name. Do you have a bunch of subroutines named 1, 2, 3, etc?
    2. Assuming you mean $i = $entry * (2 / 3);, the code will never end.
    3. In the second snippet, you are doing a numeric check, then a string check. (< is numeric, ne is string.) While this will work (because both $i and $entry will be converted to strings and compared), it's better to do numeric checks if you're dealing with numbers.

    I guess what I'm asking is - what on earth are you doing? What is $entry?

    Oh - predicability has 2 't's in it. :-)

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Re: Perl Paradigm
by Ovid (Cardinal) on Jan 29, 2003 at 21:21 UTC

    I will confess that I am most confused. What you have is not valid syntax. Is there something you have left out of your code?

    $ perl -MO=Deparse -e 'while ($i<$entry){$i = $entry (2/3)}' syntax error at -e line 1, near "$entry (" -e had compilation errors. while ($i < $entry) { ; }

    Cheers,
    Ovid

    New address of my CGI Course.
    Silence is Evil (feel free to copy and distribute widely - note copyright text)

Re: Perl Paradigm
by dbp (Pilgrim) on Jan 29, 2003 at 21:19 UTC
    I think you must be mistaken. Maybe you should post the actual code.

    Update:Is $i a number? I notice you are using ne in the second example which is for non-numeric data. Less-than will have interesting results if $i or $entry aren't numbers.