Click to See Complete Forum and Search --> : Perl unlink Question


mattmorrow
11-07-2000, 11:55 AM
My Perl script uses unlink() to delete files. It is having problems with filenames with spaces. Say that $file is "My File.doc". unlink treats all of the following as 2 files (My and File.doc):
1. unlink($file);
2. unlink("${file}");
3. $file="\"" . $file . "\"";
unlink($file); # ..and unlink("$file");

Does anyone know how to unlink files with space(s) in the name?
TIA, matt

TheLinuxDuck
11-07-2000, 03:42 PM
I just created this script:

#!/usr/bin/perl -w
use strict;
my($file)="File Name";
unlike($file);


It worked fine. http://www.linuxnewbie.org/ubb/wink.gif

Can you post some code?

------------------
TheLinuxDuck
Wait... that's a penguin?!?!?
:wq

mattmorrow
11-07-2000, 04:10 PM
Thanks for the assist.

I've got it working using the #3 example in my original post. Must have been a brain fart...

Sweede
11-07-2000, 04:18 PM
it seems like if you use
my($file) = "file name.txt";
perl automaticly escapes it correct?

::makes note that php escapes everything automaticly anyways::

http://www.linuxnewbie.org/ubb/wink.gif

takshaka
11-07-2000, 09:09 PM
Originally posted by Sweede:
it seems like if you use
my($file) = "file name.txt";
perl automaticly escapes it correct?

What the hell are you talking about?