kalyanrajsista has asked for the wisdom of the Perl Monks concerning the following question:
Hello all
I'm trying to strip off offensive characters from filename with the below snippet written long back (not by me) and is not doing what exact I want.
use strict; use warnings; print cleanfilename('abcdefghijklmnopqrstuvwxyz.xml'); sub cleanfilename { my ($ans) = @_; $ans =~ y/\/\\[]{}()?*#$^&@*;''""``<>%|//d; $ans =~ y/[[:space:][:cntrl:]]//d; return $ans; }
Output
bdfghijkmoquvwxyz.xm
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Strip filename
by almut (Canon) on Dec 22, 2009 at 09:01 UTC | |
|
Re: Strip filename
by Ratazong (Monsignor) on Dec 22, 2009 at 08:57 UTC | |
by kalyanrajsista (Scribe) on Dec 22, 2009 at 11:48 UTC | |
by almut (Canon) on Dec 22, 2009 at 12:09 UTC | |
|
Re: Strip filename
by Anonymous Monk on Dec 22, 2009 at 18:04 UTC |