spaces in paths

Discussion in 'Perl Misc' started by Eric.Medlin@gmail.com, Aug 29, 2005.

  1. Guest

    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.
     
    , Aug 29, 2005
    #1
    1. Advertising

  2. 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
     
    Gunnar Hjalmarsson, Aug 29, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Noah
    Replies:
    5
    Views:
    826
  2. Luke -

    Spaces in UNC paths

    Luke - , Oct 17, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    1,316
    John Timney \(MVP\)
    Oct 17, 2006
  3. John B. Matthews
    Replies:
    4
    Views:
    684
    John B. Matthews
    Sep 12, 2008
  4. Luke -

    Spaces in UNC Paths

    Luke - , Oct 17, 2006, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    153
    Luke -
    Oct 17, 2006
  5. Ohad Lutzky

    Paths, gentleman, paths

    Ohad Lutzky, Nov 6, 2006, in forum: Ruby
    Replies:
    2
    Views:
    216
    David Vallner
    Nov 7, 2006
Loading...

Share This Page