Jul 4, 2009, 10:41 AM
Post #2 of 3
Re: [masaniparesh] support spaces in checking file existence
[In reply to]
I want to check if file that contain spaces is exists or not. I tried below method but none worked. Could you help me out.
my $path = "'/tmp/test file'";
my $path = '/tmp/test?file';
my $path = "/tmp/test\\\ file";
my $path = "/tmp/test\ file";
For all above cases, I executed "print "$path is exists\n" if(-e $path);" and it didn;t print message any time.
The space character is a special character only to the shell, not Perl. You don't have to do anything special to include them in a literal string.
my $path = '/tmp/test file';
my $path = "/tmp/test file";
I love Perl; it's the only language where you can bless your thingy.
Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.
Get Markup Help. Please note the markup tag of "code".