Over a million developers have joined DZone.

Perl: Dirify String

·
Clean up a string for creation of a directory named using the string.


my $dir = dirify('The s^#%@$!#! title ever');     # outputs 'The-S-Title-Ever'

sub dirify {
    my $s = shift;

    $s =~ s!<[^>]+>!!gs;            # Remove HTML tags.
    $s =~ s!
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}