in reply to lenght ()Decapitated?

There are some issues with your code:

First of all, the function is named length, not lenght (and it took me a loong time to learn that length and width are written that way and not lenght and widht...)

Then, you're using gt to compare numbers. While that's technically OK, it will give you surprising results if you expect 1000 to be larger than 16.

If your code "dies", it's always instructive to tell us the error message.

Replies are listed 'Best First'.
Re^2: lenght ()Decapitated?
by JavaFan (Canon) on Nov 24, 2009 at 10:14 UTC
    Another surprise is if you expect '2' not to be greater than '16'.
Re^2: lenght ()Decapitated?
by RobinVossen (Initiate) on Nov 24, 2009 at 10:46 UTC

    Thanks for mocking my Dyslexia.. XD
    It even took me a while to see the difference when you typed them next from each other.. lol
    And I used > before but I heard that its better to use gt but Ill change it back ^^

    Oh and the dies thing.. Well as its CGI I dont see the error.. ;)
    Thanks

      So first run your program from the command line, to see the errors. Then, later on, run it on the web host as CGI with CGI::Carp qw(fatalsToBrowser), and take a look into the webserver error log.

        From the Command line I wont see the error ;) I always run it with -wc first. The Webserver wont error on me. But the last thing, Carp is good to hear about =) thanks..


        Cheers, Robin
      I heard that its better to use gt

      Just to clarify: use gt when comparing text, use > when comparing numbers.

      Dyslexia should not enter into it.
      When showing code, copy and paste it into your code tags, rather than retyping it.

      Everybody makes typoes when banging out code, but with a copy/paste, it is a lot harder to hide the original problem under new bugs.

      We're not mocking your dyslexia, we're identifying the problem you've asked us to identify. If you were to check your web server's error log, you'd see your program is dying with the error

      Undefined subroutine &main::lenght called at ...
      You seem to have forgotten the context of that lesson.
      $ perl -le' print "gt w str: ", "b" gt "a" ? "ok : "XXX"; print "> w str: ", "b" > "a" ? "ok : "XXX"; print "gt w num: ", 16 gt 2 ? "ok : "XXX"; print "> w num: ", 16 > 2 ? "ok : "XXX"; ' gt w str: ok > w str: XXX b comes after a, but ">" said otherwise gt w num: XXX 16 comes after 2, but "gt" said otherwise > w num: ok