biswanath_c has asked for the wisdom of the Perl Monks concerning the following question:
Hi
I am using a simple perl script that would list the names of the files in a specified directory (using glob command). But when i pass a path that has a space in a folder, the code fails! How do i escape the blank spaces in folder names>
Code shown below:
$input_folder = $ARGV[0]; print "input : $input_folder \n"; @inp_files = glob("$input_folder" . "\\*.*"); foreach $inp(@inp_files) { print "$inp" . "\n"; @filename = split(/\\/, "$inp"); $levels = scalar @filename; my $name = $filename[$levels - 1]; print "\t\t\t File Name : $name \n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Spaces in folder names...
by ikegami (Patriarch) on Oct 14, 2009 at 01:59 UTC | |
by biswanath_c (Beadle) on Oct 14, 2009 at 03:55 UTC | |
Re: Spaces in folder names...
by swampyankee (Parson) on Oct 14, 2009 at 02:20 UTC | |
by ikegami (Patriarch) on Oct 14, 2009 at 04:02 UTC | |
by swampyankee (Parson) on Oct 14, 2009 at 20:45 UTC |
Back to
Seekers of Perl Wisdom