Acme-Pano-Util
view release on metacpan or search on metacpan
lib/Acme/Pano/Util.pm view on Meta::CPAN
our $VERSION = '0.011';
=head1 SYNOPSIS
This module provides various random utilities that Pano Papadatos made.
=head1 EXPORT
toBareword - Converts any string to a string with only letters, underscores and numbers that does not start with a number (bareword)
fromBareword - Converts a string that was returned using toBareword back to its original form
=head1 SUBROUTINES/METHODS
=head2 toBareword
Usage: converts any string to a string with only letters, underscores and numbers that does not start with a number (bareword)
Arguments: (0) the string to convert
Returns: the converted string
Conversion Method
- A single underscore is converted into 2 _s
- A single zero is converted into 2 0s
- A number is converted into _number (To catch things that start with numbers)
- Any non [a-zA-Z] character is converted into _0_ plus its numeric value (ord) (e.g. _123)
=cut
sub toBareword {
my ($string) = @_;
return if(!defined($string));
$string =~ s/_/__/g;
$string =~ s/0/00/g;
( run in 0.328 second using v1.01-cache-2.11-cpan-0d8aa00de5b )