There is no cleaner easy way. In general, the cleanest solution
is to change your perl program to deal with case sensitive
file systems correctly, and just generally program
portably. See also
perlport.
Note that a -f does not test for
file a exsitence alone -- it also checks if it's
a "regular" file (not a directory, device, pipe, etc.)
(If you want to test for file exsitence, alone, that would
be -e.)
Also, note that your regex does not match the way you think
it does.
- it will match parts of a string. So
a file called "test1" will be said to exsit by it if
a file called "test10" exsits,
- metacharacters are
not escaped, so "." will not mean the "." character itself
but any character (except newline) when matching filenames.
You could fix these problems with using a regex, but
your are probably better off using either
lc or
uc and
eq, e.g.:
my($exsits) = grep { lc($file) eq lc($_) } readdir DIR
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.