Sanitize - Returns a sanitized version of strings
use Sanitize; sanitize("fd gfd*#(sd)", alpha => 1); # Returns: "fggfdsd" sanitize("The ip is 192.168.3.53:80", ip => 1); # Returns: "192.168.3.53" sanitize("The ip is 192.168.3.53:80", port => 1); # Returns: "80" sanitize("The ip is 192.168.3.53:80", ip => 1, port => 1); # Returns: "192.168.3.53:80" sanitize("Blah", password => 1); # Returns: "****" sanitize("sf d54_d <script>alert('test');", html => 1); # Returns: "sf d54_d <script>alert('test');" sanitize("Some email is: joe@test.com, email me now", email => 1); # Returns: "joe@test.com" sanitize(" some thing ", rtrim => 1); # Returns: " some thing" sanitize(" some thing ", ltrim => 1); # Returns: "some thing " sanitize(" some thing ", nospace => 1); # Returns: "something" sanitize("This is a %3Cscript%3Ealert('test');", noquote => 1, noencoding => 1); # Returns: "This is a scriptalert(test);" validate("invalid email@some!host", email => 1); # Returns: 0 validate("10.0.0.1", ip => 1); # Returns: 1 validate("invalid.ip.7.4", ip => 1); # Returns: 0
This module offers simple ways to sanitize or validate string inputs against a number of possible criteria.
Returns a sanitized version of the input.
Validates whether the input matches the provided criteria.
Matches alphanumeric characters.
Matches hexadecimal characters.
Matches numbers, either an integer value or string containing nothing but numbers.
Replaces any "<" and ">" with the encoded values "<" and ">".
Matches a valid "name"@"host" string, including valid characters for both the name and host parts.
Matches any space.
Matches any space at the end of the string.
Matches any space at the beginning of the string.
Matches any single or double quotes.
Matches any URL encoding such as "%00" or "%3F".
Replaces all characters with "*".
Matches a valid "xxx.xxx.xxx.xxx" IPv4 address.
Matches the port part of "host":"port".
Patrick Lambert, <dendory@live.ca>
Copyright (C) 2014 by Patrick Lambert
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.16.3 or, at your option, any later version of Perl 5 you may have available.
4 POD Errors
The following errors were encountered while parsing the POD:
'=item' outside of any '=over'
You forgot a '=back' before '=head1'
To install Sanitize, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sanitize
CPAN shell
perl -MCPAN -e shell install Sanitize
For more information on module installation, please visit the detailed CPAN module installation guide.