Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Quick RegExp question

by graff (Chancellor)
on Mar 05, 2008 at 02:14 UTC ( [id://672062]=note: print w/replies, xml ) Need Help??


in reply to Quick RegExp question

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://672062]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-04-23 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found