473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Helop on file name display

rajiv07
141 100+
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.

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. my @distinct_download_path=('c:/perl/examples/array');
  4.  
  5. for(@distinct_download_path){
  6. next if /^(\s)*$/;
  7. unless (opendir(DIR,$_)){ push(@download_invalid_directory,$_);}
  8.  while($file=readdir(DIR)){
  9.     next if/^(\s)*$/;
  10.      next if(($file eq ".")||($file eq ".."));
  11.     next if(-d $file); #next if $file is directory
  12.  $_=~s/(.)\/$/$1/; #remove last /
  13.  $file=$_.'/'.$file; #construct full path
  14.  
  15.  
  16.  
  17. push(@list_files_in_download_directory,$file);
  18.  }
  19.  
  20. }
  21.  
  22. print "content-type:text/html\n\n";
  23.  
  24. print join("\n",@list_files_in_download_directory);
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
Jun 3 '08 #1
3 2194
numberwhun
3,509 Expert Mod 2GB
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.

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. my @distinct_download_path=('c:/perl/examples/array');
  4.  
  5. for(@distinct_download_path){
  6. next if /^(\s)*$/;
  7. unless (opendir(DIR,$_)){ push(@download_invalid_directory,$_);}
  8.  while($file=readdir(DIR)){
  9.     next if/^(\s)*$/;
  10.      next if(($file eq ".")||($file eq ".."));
  11.     next if(-d $file); #next if $file is directory
  12.  $_=~s/(.)\/$/$1/; #remove last /
  13.  $file=$_.'/'.$file; #construct full path
  14.  
  15.  
  16.  
  17. push(@list_files_in_download_directory,$file);
  18.  }
  19.  
  20. }
  21.  
  22. print "content-type:text/html\n\n";
  23.  
  24. print join("\n",@list_files_in_download_directory);
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 am really not sure myself. My first thought is maybe the browser is stripping the unnecessary white space. I see that in viewing your post with firefox that the extra space got stripped.

Again, not sure.

Regards,

Jeff
Jun 3 '08 #2
KevinADC
4,059 Expert 2GB
Web browsers collapse multiple spaces into one space. Look in the source code of the HTML document and you will see the extra spaces, but you will not see them in the browser. This is an html issue, not a perl issue. Use some HTML code that maintains text formatting (<pre>formatted text here</pre>) or use html entities to display the extra spaces: &nbsp;

Study up on HTML.
Jun 3 '08 #3
rajiv07
141 100+
Thank You for your replies



Rajiv
Jun 4 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Abhas | last post by:
> > Hi, this is Abhas, > > I had made a video library program in C++, but was facing a problem. > > After entering 12 movies, i cannot enter any more movies. > > Something gibberish comes instead....
5
by: Codeman II | last post by:
Hi there, I am building a form where the user must upload a picture and fill in his details. Now I have a problem as all of this is on the same form. How will I be able to have the Browse...
0
by: troutbum | last post by:
I am experiencing problems when one user has a document open through a share pointing to the web site. I use the dsolefile to read the contents of a particular directory and then display them in a...
17
by: spentun | last post by:
How can I moitor file which is executed by user or program in window. I need to write a code to monitor file. When user clicks the file(.exe) or is called by program, the name of file will be...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
6
by: chris237 | last post by:
I'm having trouble with the following program. i want it to have the options to save a list of data entered by the user and display it the next time they run it. Could someone please either show me a...
2
by: rn5a | last post by:
Using the FileSystemInfo class, I am retrieving all the directories & files existing in a particular directory on the server & listing them in a ListBox. If an item in the ListBox happens to be a...
7
by: ConfusedAlot | last post by:
This is my code for a database, whenever i save the database to the file 'database.txt' and display the results i get this; name - (correct, is what i put in) pin - 3435973836 slew rate -...
9
by: tshad | last post by:
I have a Windows App that is doing some work and then writing a "Now Processing..." line to the status line of the window as well as the Textbox on the form. But the problem is that the work is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.