10 May 2016 23:42:13 UTC
- Distribution: String-Dirify
- Module version: 1.03
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (986 / 0 / 0)
- KwaliteeBus factor: 1
- 88.14% Coverage
- License: perl_5
- Activity24 month
- Download (13.21KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionRSAVAGE Ron Savageand 1 contributors
- Ron Savage (firstname.lastname@example.org)
- Method: dirify($string [, $separator])
- Melody 'v' Movable Type
- Backwards Compatibility with Movable Type
String::Dirify - Convert a string into a directory name
use String::Dirify; my($dir_1) = String::Dirify -> dirify('frobnitz');
use String::Dirify ':all'; my($dir_2) = dirify('bar baz');
use String::Dirify; my($sd) = String::Dirify -> new(); my($dir_3) = $sd -> dirify('!Q@W#E$R%T^Y');
String::Dirifyis a pure Perl module.
This module allows you to convert a string (possibly containing high ASCII characters, and even HTML) into another, lower-cased, string which can be used as a directory name.
For usage, see the Synopsis.
This code is derived from similar code in Movable Type.
Returns a string, which can be used as a directory name.
The default separator is '_'.
Each run of spaces in the string is replaced by this separator.
- 1: Each high ASCII character is replaced by its normal equivalent
- 2: The string is converted to lower case
- 3: Any HTML (including HTML entities) in the string is removed
- 4: Any characters which are not (Perl) words, spaces or hyphens, are removed
- 5: Runs of spaces are converted to the separator character
For more details about this character, see the discussion of the dirify() method (above).
See http://openmelody.org for details.
Unfortunately, the way Movable Type uses dirify() allows a fake separator - '1' - to be used for the second parameter in the call to dirify().
The '1' triggered usage of '_' as the separator, rather than the '1' provided.
This 'feature' has been preserved in
String::Dirify, but is discouraged. Instead, simply drop the second parameter and let the code default to '_'.
This module is available as a Unix-style distro (*.tgz).
See http://savage.net.au/Perl-modules.html for details.
String::Dirifystarted out as part of the Movable Type code.
Then, Mark Stosberg cut down the original code to provide just the English/ISO/ASCII features.
Lastly, the code was cleaned up, tests added, and all packaged, by Ron Savage <email@example.com> in 2009.
Copyright (c) 2009, Mark Stosberg, Ron Savage.
Copyright (c) 2010, 2011, Ron Savage.
Module Install Instructions
To install String::Dirify, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install String::Dirify
For more information on module installation, please visit the detailed CPAN module installation guide.