CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
support spaces in checking file existence

 



masaniparesh
Novice

Jul 3, 2009, 4:39 AM

Post #1 of 3 (317 views)
support spaces in checking file existence Can't Post

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.

Thansk,Paresh


shawnhcorey
Enthusiast


Jul 4, 2009, 10:41 AM

Post #2 of 3 (309 views)
Re: [masaniparesh] support spaces in checking file existence [In reply to] Can't Post


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.

Thansk,Paresh


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.

Code
my $path = '/tmp/test file';


or

Code
my $path = "/tmp/test file";


__END__

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".


masaniparesh
Novice

Jul 4, 2009, 1:51 PM

Post #3 of 3 (303 views)
Re: [shawnhcorey] support spaces in checking file existence [In reply to] Can't Post

thanks..you are correct. :-)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives