in reply to Random number in while loop

== compares numbers, but you are feeding it strings. Use eq.

perlop

Replies are listed 'Best First'.
Re^2: Random number in while loop
by Fletch (Bishop) on Jul 16, 2008 at 20:10 UTC

    More specifically as to why it never stops, Perl treats not-numbers (such as your filenames) in a numeric context as having the numeric value 0. You're basically comparing two 0s then which are always equal. Had you used warnings you would have gotten a gripe Argument "bar" isn't numeric in numeric eq (==) at file.plx line 17. Had your filenames started with $rnumber as a prefix rather than having it as a suffix you would have gotten behavior more like you expect (since Perl would treat something like "44.spoo.bak" numerically as 44).

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.