Solved

Perl CGI and scrolling_list

Posted on 1997-07-25
9
296 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now