3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-24 19:52:34 +01:00
pbot/PBot/Utils/SafeFilename.pm
Pragmatic Software 5c4e10a35c Tidy things up
2020-02-15 14:38:32 -08:00

24 lines
444 B
Perl

package PBot::Utils::SafeFilename;
use 5.010; use warnings;
use feature 'unicode_strings';
require Exporter;
our @ISA = qw/Exporter/;
our @EXPORT = qw/safe_filename/;
sub safe_filename {
my $name = shift;
my $safe = '';
while ($name =~ m/(.)/gms) {
if ($1 eq '&') { $safe .= '&'; }
elsif ($1 eq '/') { $safe .= '&fslash;'; }
else { $safe .= $1; }
}
return lc $safe;
}
1;