Over a million developers have joined DZone.

Perl: Dirify String

DZone's Guide to

Perl: Dirify String

Free Resource
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!

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}