Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

execution problem if dir name has space in it's name

by namishtiwari (Acolyte)
on Jul 08, 2009 at 14:33 UTC ( [id://778291]=perlquestion: print w/replies, xml ) Need Help??

namishtiwari has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, My Script is working fine when i put a '.' for the currect directory. But when i give a directory name which has space between it, it does not run it and did not show the files inside the directory. I am pasting piece of my code
$glob_path = "$LogDir/${Prefix}*"; @log_paths = glob $glob_path or die "No files found in '$glob_path'"; printf "log files = \n"; print @log_paths; printf "\n";
I am running the program as-
C:\Perl Script>perl summaryreport_latest_working_latest.pl --LogDir="C +:\\Perl Script\\Sample Programs" --Prefix=arcotwebfort --Diagnostics= +01096878 > results.txt
i got this as output
LOG DIR = C:\\Perl Script\\Sample Programs log files = C:\PerlScript\Sample
the actual folder name from where i need to take the file is-- <quote> C:\Perl Script\Sample Programs </quote> inside this directory we have so many files with prefix arcotwebfort. Kindly suggest something to come out of this problem. Thanks NT

Replies are listed 'Best First'.
Re: execution problem if dir name has space in it's name
by Corion (Patriarch) on Jul 08, 2009 at 14:39 UTC

    glob is stupid about spaces in filenames. You want to use File::Glob and the bsd_glob routine from it.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: execution problem if dir name has space in it's name
by arc_of_descent (Hermit) on Jul 08, 2009 at 14:47 UTC

    You're probably looking for this

    $glob_path = qq("$LogDir/${Prefix}*");

    Enclose the directory name in double quotes


    --
    Rohan
Re: execution problem if dir name has space in it's name
by raisputin (Scribe) on Jul 08, 2009 at 20:29 UTC
    How about take the spaces out of the directory names :) That is a very simple fix :) LOL

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-25 06:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found