Personally, I see no reason to avoid spaces et al. My wife has no clue what characters are special, and has no problems saving files such as "Foo's resume & cover letter.sxd". (No, her name isn't really "Foo" ;-}) And it works just fine.

What you want to use to check for bad characters is simply

$folder =~ m<[bad characters here]>;
In your case, the only bad character is the slash, so we can eliminate the brackets:
$folder =~ m</>;
As for using at the command line - this is no different than writing documents in OpenOffice.org. If you want to load it, just put it in quotes. Or, using bash on Linux, just type the first few characters and hit the tab key - all escapes will be put in automatically for filename completion (assuming it is unique to the first few letters you typed in).

If you're going to programmatically call another program, you should be learning to use the list version of system and/or exec anyway. By eliminating the shell, you don't need to worry about special characters.

system('/usr/bin/ooffice', $filename);
Whether $filename has spaces, or any other special character, or not, doesn't matter. It just works.


In reply to Re^3: checking for reserved characters by Tanktalus
in thread checking for reserved characters by Real Perl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.