Helop on file name display

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajiv07
    New Member
    • Jun 2007
    • 141

    Helop on file name display

    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
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Originally posted by rajiv07
    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 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

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      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>formatte d text here</pre>) or use html entities to display the extra spaces: &nbsp;

      Study up on HTML.

      Comment

      • rajiv07
        New Member
        • Jun 2007
        • 141

        #4
        Thank You for your replies



        Rajiv

        Comment

        Working...