I use the "use File::Glob ':glob'" method for windows paths with spaces in.
The variable that I pass into this function is read in from a configuration file and can be "C:\Program Files" (directory name) and can also be "logs\app.log" (specific filename).
When I specify a directory with spaces in, "use File::Glob ':glob'" works, but when I specify a specific filename with no spaces in, I get error "Out of memory!"
So at the moment, I have to use "use File::Glob ':glob'" for directories with spaces in and I have to comment out "use File::Glob ':glob'" to get round the "Out of memory!" error when I specify a specific filename with no spaces in.
What I need is my script to not need altering between these two types of file specification.
Please do you know of any what that I can do this.
Thank you.
Richard Thomas.
If all you want to do is do is glob with a file pattern that contains spaces; for example:
my $search = "C:\Program Files\Apache Group\Apache2\logs\*.log"
You can use
use File::Glob ':glob'
my @files = bsd_glob("$search");
Which would return a return a list of all the log files.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: Thursday, January 23, 2003 8:44 AM To: [EMAIL PROTECTED] Subject: RE: Problem with path containing spaces
[EMAIL PROTECTED] writes:
> > The doco for File::DosGlob says that spaces are used to delimit > > multiple patterns, and that in order to include patterns containing > > spaces you should escape them with double quotes or backslashes, e.g. > > > > @hexfiles=glob("\"$dir/*.hex\""); > > Now this is funny... Now it doesn't work with paths *without* space(s)...
Hey, you're right. I checked the code, and it only uses Text::ParseWords if there is a space in the pattern, so sticking quotes around a pattern will not work for paths without a space, as you discovered. The alternative is to escape spaces with backslash, e.g
$dir =~ s/ /\\ /g; @hexfiles=glob("$dir/*.hex");
HTH
-- Brian Raven
Odd that we think definitions are definitive. :-) -- Larry Wall in <[EMAIL PROTECTED]>
----------------------------------------------------------------------- The information contained in this e-mail is confidential and solely for the intended addressee(s). Unauthorised reproduction, disclosure, modification, and/or distribution of this email may be unlawful. If you have received this email in error, please notify the sender immediately and delete it from your system. The views expressed in this message do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary companies. -----------------------------------------------------------------------
_______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_________________________________________________________________ Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile
_______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
