irah 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: restriction in input
by Corion (Patriarch) on Jan 29, 2009 at 14:06 UTC

    It would help us to help you better if you told us, exactly how you are getting input from your user. For example, if the user fills in an HTML form, a possible approach is the MAXLENGTH attribute:

    <input type="text" name="irah" maxlength="10 value="">

    Otherwise, there are the length and substr functions. Looking at the questions you ask, maybe reading perlfunc and a good introductory book to Perl would be in order?

      For example, I am getting user name from stdin. I restricted the user name must be less than 15 characters. So when user try to type 16th character, I won't allow the user to type. How can I achieve in Perl.
        I would handle this by just using the normal chomp($name = <STDIN>), checking its length, and then prompting the user to either accept the truncated name (eg much_too_long_name would become much_too_long_n) or to re-enter a shorter name. A simple looping prompt. You would do something similar if you were looking for a number and the user entered a string.
Re: restriction in input
by prasadbabu (Prior) on Jan 29, 2009 at 14:08 UTC
Re: restriction in input
by Bloodnok (Vicar) on Jan 29, 2009 at 14:07 UTC
    At the risk of repeating myself, see Re: remove function.

    A user level that continues to overstate my experience :-))