Hi to all,
I have a script to list the file names in a directory .When i run this script locally (command prompt) it displays the exact file name (even though the file name has two spaces).But i upload the script into server (Browser) it shows trimmed file names(single space for double spaces).
I have checked both IE and Firefox it shows only single space file name instead on double space file name. Is it browser problem.
[CODE=perl]#!/usr/bin/perl
my @distinct_downl oad_path=('c:/perl/examples/array');
for(@distinct_d ownload_path){
next if /^(\s)*$/;
unless (opendir(DIR,$_ )){ push(@download_ invalid_directo ry,$_);}
while($file=rea ddir(DIR)){
next if/^(\s)*$/;
next if(($file eq ".")||($fil e eq ".."));
next if(-d $file); #next if $file is directory
$_=~s/(.)\/$/$1/; #remove last /
$file=$_.'/'.$file; #construct full path
push(@list_file s_in_download_d irectory,$file) ;
}
}
print "content-type:text/html\n\n";
print join("\n",@list _files_in_downl oad_directory);[/CODE]
Script Output For local run
-------------------------------------
c:/perl/examples/array/data structure.pl
c:/perl/examples/array/dumper.pl
c:/perl/examples/array/rajiv gandhi.pl# here the file name actually has two spaces between rajiv and gandhi but it shows only one space.
Script Output For server run
-------------------------------------
c:/perl/examples/array/data structure.pl
c:/perl/examples/array/dumper.pl
c:/perl/examples/array/rajiv gandhi.pl
Please help me.
Regards
Rajiv
I have a script to list the file names in a directory .When i run this script locally (command prompt) it displays the exact file name (even though the file name has two spaces).But i upload the script into server (Browser) it shows trimmed file names(single space for double spaces).
I have checked both IE and Firefox it shows only single space file name instead on double space file name. Is it browser problem.
[CODE=perl]#!/usr/bin/perl
my @distinct_downl oad_path=('c:/perl/examples/array');
for(@distinct_d ownload_path){
next if /^(\s)*$/;
unless (opendir(DIR,$_ )){ push(@download_ invalid_directo ry,$_);}
while($file=rea ddir(DIR)){
next if/^(\s)*$/;
next if(($file eq ".")||($fil e eq ".."));
next if(-d $file); #next if $file is directory
$_=~s/(.)\/$/$1/; #remove last /
$file=$_.'/'.$file; #construct full path
push(@list_file s_in_download_d irectory,$file) ;
}
}
print "content-type:text/html\n\n";
print join("\n",@list _files_in_downl oad_directory);[/CODE]
Script Output For local run
-------------------------------------
c:/perl/examples/array/data structure.pl
c:/perl/examples/array/dumper.pl
c:/perl/examples/array/rajiv gandhi.pl# here the file name actually has two spaces between rajiv and gandhi but it shows only one space.
Script Output For server run
-------------------------------------
c:/perl/examples/array/data structure.pl
c:/perl/examples/array/dumper.pl
c:/perl/examples/array/rajiv gandhi.pl
Please help me.
Regards
Rajiv
Comment