namishtiwari 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: Specaila characters string not coming in final output file
by BioLion (Curate) on Aug 07, 2009 at 15:02 UTC

    Is this a similar problem to the one you had earlier ( special characters storage in perl )? What was wrong with the answers you got there? Have you tried inserting checks to see where the special characters are being lost like deadpiratepeter suggested?

    Just a something something...
      Yes i did try some options by googling , but i could not get it working. It fails when a user name contains a special character. Thanks NT
Re: Specaila characters string not coming in final output file
by SuicideJunkie (Vicar) on Aug 07, 2009 at 15:08 UTC

    Way too long.

    If you're having trouble with usernames, trim it down to just that fragment. Throw that fragment into a test.pl, and print to see what it is doing with explicit inputs.


    I did notice that you are removing only whitespace from the username. Specifically, you are not removing quote characters from the name.

    Consider what happens if $User_Name = " joe's name here ";Then, your

    $User_Name= "'" . $User_Name . "'";
    Results in 'joe's name here' which has mismatched quotes.

    In general, do not filter out bad characters. Instead, only allow good characters. That way if you miss one, you're not hosed.

    $User_Name =~ s/[^a-zA-Z0-9]//g;
    might be a better choice, or simply s/\D//g; if you want only numbers.

      Thanks for the reply, but i do not have any exceptions in user name as you pointed out in joe example.Later i need to print those values in the file, if i take out the special characaters from the user name it will not have any meaning. So i need to do something within limitations. Is my apporaoch for special character handling is correct. Thanks NT

        SuicideJunkie is right - namishtiwari you need to cut down your code to something that makes the problem more clear and provide us with examples which clearly demonstrate 'expected' and 'unexpected' results, otherwise it is very hard to help you!

        And show us what you have tried! There are also many nodes here about dealing with special characters : SuperSearch.

        If you cannot enforce user name content, you might try escaping the characters s/([ special characters ])/\\$1/g ?

        Just a something something...