Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > spaces in paths

Reply
Thread Tools

spaces in paths

 
 
Eric.Medlin@gmail.com
Guest
Posts: n/a
 
      08-29-2005
The following code doesn't print out the file list.

#!/usr/bin/perl

$inFolder = "~/folder space";
@folders = <$inFolder/*>;
print "@folders\n";

Adding double quotes around like @folders = <"$inFolder"/*>; fixes the
problem, but then
$inFolder = "~/folder_nospace"; doesn't print out anything. How do I
get it print out the file list all the time.

 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      08-29-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> The following code doesn't print out the file list.
>
> #!/usr/bin/perl
>
> $inFolder = "~/folder space";
> @folders = <$inFolder/*>;
> print "@folders\n";
>
> Adding double quotes around like @folders = <"$inFolder"/*>; fixes the
> problem, but then
> $inFolder = "~/folder_nospace"; doesn't print out anything. How do I
> get it print out the file list all the time.


You may want to try:

$inFolder =~ s/ /\\ /g;

Or, probably safer, use opendir() and readdir() instead.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How to trim a String trailing spaces, but not leading spaces? John B. Matthews Java 4 09-12-2008 05:28 AM
Paths, gentleman, paths Ohad Lutzky Ruby 2 11-07-2006 02:15 AM
Spaces in UNC paths Luke - eat.lemons@gmail.com ASP .Net 3 10-17-2006 07:46 PM
Spaces in UNC Paths Luke - eat.lemons@gmail.com ASP .Net Web Services 2 10-17-2006 03:20 PM
Convert between Windows style paths and POSIX style paths Noah Python 5 07-11-2003 09:25 PM



Advertisments