Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Quick RegExp questionby graff (Chancellor) |
on Mar 05, 2008 at 02:14 UTC ( [id://672062]=note: print w/replies, xml ) | Need Help?? |
As Tanktalus said, you want m/\s/.
But watch out. If a space in the file name can cause a given script to crash, there are other bad things that can also turn up in file names (also as a result of "pilot error", but hey, it happens, as we all know), and these can do more damage than just crashing your script. (I've seen some MS-Windows users put ampersands in file names. Imagine the fun you can have with that in a unix shell environment.) My point is: If the script crashes because there is a space in the file name, there is actually a deeper problem with the script, in terms of what it is doing with the variable(s) that hold the file name(s) -- e.g. passing the variable as part of a quoted string to a shell command (in back-ticks or in a "system()" call) -- and it would be very prudent to fix that (using quotemeta, multi-arg system call, totally different logic, etc). Now. Before the next "unexpected" mistake turns up in a file name.
In Section
Seekers of Perl Wisdom
|
|