Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Keep It Simple, Stupid
 
PerlMonks  

Handling Special Character: Best Practices?

by FitTrend (Pilgrim)
on Apr 12, 2005 at 14:53 UTC ( #447022=perlquestion: print w/ replies, xml ) Need Help??
FitTrend has asked for the wisdom of the Perl Monks concerning the following question:

I've personally written several (simple and complex) web applications that utilize different programming technologies to accomplish my goals. One of the most reoccuring issues that I run into is handling special characters for different things. For example:

  • Passing Special characters to/from URLs to launch a different tool and pass parameters (some specified by a user)
  • Escaping special characters in perl code
  • formatting special characters for HTML to create pretty tables (etc) that includes user input from previous screens in the application
  • subsituting special characters for databases to avoid errors based on users who need/require %, _, ', and " in their input fields

I've realized for some time now that it is cumbersome to handle/convert between these different technologies within the main program. I even use some great perl modules from CPAN.

Generally each technology has its own methods I find.

  • URL: using URL Encoding (example)
  • Escaping with backslashes or regex
  • HTML Formatting: &gt for >, etc.
  • Subsituting special character for database storage
    $sth = $dbh->prepare("update rpttemplates set name=?, where rpttemplat +es_id ='$input{'id'}'"); $sth->execute($input{'name'});

I know there are some great modules out there to perform the formatting some of these tasks. I was curious on what my fellow monks do to handle all this data and converting it back and forth to perform the tasks typical of web based applications. What are some best practices that you follow?

Comment on Handling Special Character: Best Practices?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://447022]
Approved by moot
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2014-04-19 08:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (478 votes), past polls