Solved

Perl CGI and scrolling_list

Posted on 1997-07-25
9
313 Views
Last Modified: 2009-07-29
I have created an array (@desc) which I am loading into a scrolling_list.  The array is built from a file.  THe file contains lines like:  name      desc
                      another      desc  
The problem is that when the list is diplayed, the space in
between the columns disappears.  It is displayed as:
                     name desc
                     another desc
If I print the array to a file, the columns are preserved. Is the scrolling_list automatically removing extra white space?  It leaves ONE space but not more than that?  

Can I preserve my columns?

For now I have dots as a spacer.  name.....desc but I'd rather use tabs.
0
Comment
Question by:wspoulin
  • 5
  • 2
  • 2
9 Comments
 

Author Comment

by:wspoulin
ID: 1205028
Well, I have just reviewed my question and see that my extra
white space has been removed!!!  I guess I know the answer!

Still, I'd like to know if there is a way around it.

For clarification my file looks like:

      name<spaces or tab........> desc
      another name<spaces or tab> desc2

But my display looks like:

      name desc
      another name desc2
0
 
LVL 2

Expert Comment

by:n3mtr
ID: 1205029
What is scrolling_list?  Did you write it yourself or is it part of some package?
Is this displayed on a browser?  Browsers get rid of extra spaces. You could convert to tables(better), or convert to non breaking spaces(&nbsp).

0
 
LVL 2

Expert Comment

by:n3mtr
ID: 1205030
Another thing, if its not displayed on a web browser you could modify scrolling list to not get rid of the extra spaces.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:wspoulin
ID: 1205031
scrolling_list is part of CGI.pm. It is displayed in Netscape.

The code is as follows:

$query->scrolling_list(
  -name=>'projects',
  -values=>[@some_names],
  -default=>$selected,
  -size=>15,
  -onChange=>"refresh()");

@some_names has rows consisting of:   name (tabs) desc

When you say convert to &nbsp do you mean to store &nbsp in the array?  I have tried that and it dispalys: "name&nbsp desc"!



 
When you say, "convert to ... (&nbsp)" do you mean in the array?

0
 
LVL 5

Accepted Solution

by:
julio011597 earned 50 total points
ID: 1205032
It is "&nbsp;", you missed last char.
It follows the rules for non-printable chars's symbolic names.

Another *nice* workaround is putting your list inside the pair <PRE>...</PRE>; let tabs stay into the list and try this.

Cheers, julio
0
 

Author Comment

by:wspoulin
ID: 1205033
I have tried everything!  I have put &nbsp; in the file that
fills the array.  
I have put the <PRE> tags on each line:
$format = "<PRE>".$desc."</PRE>; push(@desc,$format);

I have put the <PRE> tags as part of the list:
push(@desc,"<PRE>");
push(@desc,$data);
push(@desc,"</PRE>");

Scrolling list is part of CGI.pm.  
HELP!  I am forced to display my data as "data.....desc" YUK!
0
 

Author Comment

by:wspoulin
ID: 1205034
I have tried everything!  I have put &nbsp; in the file that
fills the array.  
I have put the <PRE> tags on each line:
$format = "<PRE>".$desc."</PRE>; push(@desc,$format);

I have put the <PRE> tags as part of the list:
push(@desc,"<PRE>");
push(@desc,$data);
push(@desc,"</PRE>");

Scrolling list is part of CGI.pm.  
HELP!  I am forced to display my data as "data.....desc" YUK!
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1205035
No, i meant the html looking something like:

<PRE>
<SELECT...>
<OPTION...>
...
</SELECT>
</PRE>

so, in your code, output the 'PRE' tags before and after the list object.

Going back to your question, surrounding the list with <PRE>...</PRE> would allow you to put any spaces or tabs you need and get them preserved when displayed.

Anyway, i cannot guess why the "&nbsp;" didn't work.
As a suggestion, you could try to get rid of the scrolling_list object, and set up the corresponding code yourself (just a matter of a few print()'s): sometimes, working with third parties libraries may cause just headaches!

-julio
0
 

Author Comment

by:wspoulin
ID: 1205036
Well, I give up!  PRE tags do not preserve it either.  I
think you are correct about the third party utils.  Maybe I
need an upgrade.  

But I will just type the code myself for now.

Thanks for the help!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
binary to char / hexadecimal 5 121
Perl DBI Transactions Using Custom Module 7 48
Migrate OTRS to newest version. 1 387
PERL - Find newest folder 12 151
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question