473,394 Members | 1,043 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,394 software developers and data experts.

Generate a Table of contents using file open loop not working.

I am looking to build a regular expression that will match pTOC(somenumber)
where the number varies between 1& ten, this is to generate a table of contents file that I desperately need to display in my online help tab within an existing web application. I am still fairly new to perl if anyone could help me do this I will be forever in your debt.
existing code that needs to be fixed for new file.
Expand|Select|Wrap|Line Numbers
  1. if ( $Request->ServerVariables("SERVER_NAME")->item() =~ /mlxhelp/ ) {
  2.         my $toc_file = ( $Session->{'usrType'} eq 'Pro' ) ? 'c:\SupportWeb\NerfHerder\Content\HELP\PRO\TOC.html' : 'c:\SupportWeb\NerfHerder\Content\HELP\STD\TOC.html';
  3. my $user_type = uc $Session->{'usrType'};
  4.  
  5. open TOC, $toc_file;
  6. my @toc_lines = <TOC>;
  7. close TOC;
  8.         foreach my $line ( @toc_lines ) { 
  9.             $content .= qq^<rlink tab="Help" script="frames['help_iframe'].location.href='Content/HELP/$user_type/$1'" title="$3">
  10.                     </rlink>^ if ( $line =~ /<p class="pTOC1"><a href="(.*?)"\s+target="(.*?)">(.*?)<\/a>/ );
  11.         }
  12.         $content .= '</leftIndex>';
  13.  
  14.     }
The new file is in a different location, which has already been adjusted for, user_type is a variable which switches location between standard product and an optional upgrade product (not needed for new product at all and has been removed) $1 should be taking pTOC and re-writing it to leftIndex which is of course the left index of a frameset..
Sep 21 '07 #1
5 1404
KevinADC
4,059 Expert 2GB
This should get you started:

Expand|Select|Wrap|Line Numbers
  1. open TOC, $toc_file;
  2. my @toc_lines = <TOC>;
  3. close TOC;
  4. foreach my $line ( @toc_lines ) {
  5.    if ( $line =~ /<p class="(pTOC\d+)"><a href="(.*?)"\s+target="(.*?)">(.*?)<\/a>/ ) {
  6.       $content .= qq{<rlink tab="Help" script="frames['help_iframe'].location.href='Content/HELP/$user_type/$1'" title="$3"></rlink>};
  7.    }
  8.    $content .= '</leftIndex>';
  9. }
Sep 21 '07 #2
This should get you started:

Expand|Select|Wrap|Line Numbers
  1. open TOC, $toc_file;
  2. my @toc_lines = <TOC>;
  3. close TOC;
  4. foreach my $line ( @toc_lines ) {
  5.    if ( $line =~ /<p class="(pTOC\d+)"><a href="(.*?)"\s+target="(.*?)">(.*?)<\/a>/ ) {
  6.       $content .= qq{<rlink tab="Help" script="frames['help_iframe'].location.href='Content/HELP/$user_type/$1'" title="$3"></rlink>};
  7.    }
  8.    $content .= '</leftIndex>';
  9. }
Thanks kevin, it still isn't working for me but I appreciate the help, I am going over to my buddies who is also a web designer (he has a lot more experience than i do with perl maybe he can help me out). If if find what the problem is I will write back and let you know.
Oct 4 '07 #3
This should get you started:

Expand|Select|Wrap|Line Numbers
  1. open TOC, $toc_file;
  2. my @toc_lines = <TOC>;
  3. close TOC;
  4. foreach my $line ( @toc_lines ) {
  5.    if ( $line =~ /<p class="(pTOC\d+)"><a href="(.*?)"\s+target="(.*?)">(.*?)<\/a>/ ) {
  6.       $content .= qq{<rlink tab="Help" script="frames['help_iframe'].location.href='Content/HELP/$user_type/$1'" title="$3"></rlink>};
  7.    }
  8.    $content .= '</leftIndex>';
  9. }
Kevin I think the problem is the characters in the helpfile, I noticed that the previous TOC had regular links some of the links in the new toc are like this example below would this cause the re-write to fail and if so how would i adjust so it works again?
<a href="gettingstarteda3.html#wp1318504" target="Tempo_help_frame">

etc.
Oct 5 '07 #4
KevinADC
4,059 Expert 2GB
Can you post a sample of the real data you are trying to parse?
Oct 5 '07 #5
Can you post a sample of the real data you are trying to parse?
I also am having problems with switching from one to the other.
what I currently have switches from a free subscription to a pay for or to (tempo)
I would like to just display tempo if (site is eq to (list of sites) otherwise it should do the old test without the tempo element. .
The previous coder loved inline if statements (which I absolutely hate, because I find them very confusing. I would like to rewrite not to use these, but I am so new I am not sure how to)

Expand|Select|Wrap|Line Numbers
  1. <h2 class="pTOCTitle">Table of Contents</h2>
  2.  <p class="pTOC1"><a href="Tempo_help-08-1.html" target="Tempo_help_frame">Getting Started</a></p>
  3.   <p class="pTOC2"><a href="gettingstarted2.html" target="Tempo_help_frame">Signing In and Out</a></p>
  4.   <p class="pTOC2"><a href="gettingstarteda3.html" target="Tempo_help_frame">What's On the Home Page?</a></p>
  5.    <p class="pTOC3"><a href="gettingstarteda3.html#wp1318504" target="Tempo_help_frame">Header Bar Controls</a></p>
  6.    <p class="pTOC3"><a href="gettingstarteda3.html#wp1318527" target="Tempo_help_frame">Main Menu Bar</a></p>
  7.    <p class="pTOC3"><a href="gettingstarteda3.html#wp1318559" target="Tempo_help_frame">My Sidebar</a></p>
  8.    <p class="pTOC3"><a href="gettingstarteda3.html#wp1318563" target="Tempo_help_frame">Prospecting Matches</a></p>
  9.    <p class="pTOC3"><a href="gettingstarteda3.html#wp1318574" target="Tempo_help_frame">Find a Listing</a></p>
  10.    <p class="pTOC3"><a href="gettingstarteda3.html#wp1318585" target="Tempo_help_frame">Hotsheet</a></p>
  11.    <p class="pTOC3"><a href="gettingstarteda3.html#wp1318599" target="Tempo_help_frame">Inventory Watch</a></p>
  12.   <p class="pTOC2"><a href="gettingstarted4.html" target="Tempo_help_frame">Using the MLS, Broker and Office Tabs</a></p>
  13.   <p class="pTOC2"><a href="gettingstarted5.html" target="Tempo_help_frame">Identity Sharing</a></p>
  14.  <p class="pTOC1"><a href="Tempo_help-02-1.html" target="Tempo_help_frame">The Basics</a></p>
  15.   <p class="pTOC2"><a href="basics2.html" target="Tempo_help_frame">A Look at the Main Interface</a></p>
  16.    <p class="pTOC3"><a href="basics2.html#wp1308985" target="Tempo_help_frame">Collapsing/Expanding the Main Menu</a></p>
  17.    <p class="pTOC3"><a href="basics2.html#wp1309017" target="Tempo_help_frame">Links</a></p>
  18.   <p class="pTOC2"><a href="basics3.html" target="Tempo_help_frame">Field Related Controls</a></p>
  19.  
Oct 9 '07 #6

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

Similar topics

3
by: Dave Nouwens | last post by:
Hi All, Please accept my appologies in advance for what I expect will be a reasonably simple question. I have an html form (which is generated in php) which contains a number of rows (one row...
3
by: Mike | last post by:
I am just wondering if it is possible to save a HTML string from PHPs? Let me elaborate more on what I mean. If you do <?php include 'abc.php' ?> //abc.php <html>
3
by: Phil Rutter | last post by:
Hello All, I have about 700 word documents that have 2 tables one is static 4 colums x 5 rows the other is 5 colums x rows ranging from 2 to 100 what i wolud like to do is open the word doc....
10
by: John Smith | last post by:
I know that uploading an image to a database has been covered, oh, about 3 trillion times. However, I haven't found anything covering uploading to a MySQL database with .net. Please don't...
1
by: Beowulf | last post by:
I have a report laid out in Design View as shown at the end of this message. I have code that performs the following steps: 1. In main report's Report_Open(), DELETE any old rows in tblTOC for...
9
by: mabond | last post by:
Hi My text file varies in size on each occasion it is processed (i.e different number of lines) Contents are coma separated, giving data for each column in my sql table (number of columns is...
4
by: Kevin Blount | last post by:
As mentioned before, I'm creating a multi-lingual page where the text of the page comes from a database. This page includes a registration form which asks for address information, including the...
7
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
11
by: blunt | last post by:
trying to write a program to write the configuration files for a load of wireless access points. i've never been a good programmer and haven't done any for nearly a decade so have obviously made some...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.