Hey Monks,

This is a very big program, so it might be, that I wont get an answer here, due to not understanding what do I seek help for, I'll try my best to explain.

--------------------------------------------------------

I have a problem when I create HTML pages with PERL. I use 2 Arrays. In FirstArray there are more elements than in SecondArray.

When I start to create HTML's, I use in one of the Navigation Menus the list of elements in FirstArray.

When you chose one element in the menu, it will open a new HTML (firstArray1.html) that wil display some statistics in a chart.

That HTML has two buttons below the chart: FirstArray and SecondArray (name of buttons).

If you click on SecondArray it will switch from current HTML (firstArray1.html) to (secondArray1.html). And then again if you click on FirstArray button it will switch to (firstArray1.html). The problem is that the FirstArray has more elements than SecondArray. And those elements that are NOT in the SecondArray are causing problems: Lets say we are in firstArray5.html and by clicking SecondArray button the page will try to load secondArrray5.html - HOWEVER there is NONE, because secondArray does not have that element as firstArray has.

I have to keep the code as it is (all other 1000 lines of code). I have a seperate sub where I create the buttons:

sub createButtons{ ($outfile,$filename)=@_; $replace = 'ay'; $find = 'DFT'; if(index($filename, $find) != -1){ $filenameDFT = $filename; $filenameLAY = $filename; $filenameLAY =~s/$find/$replace/; print $outfile " <a href='./$filenameLAY' class='button_l +ay'>Layout</a> <a href='./$filenameDFT' class='button_dft'> +DfT</a>\n </div>\n"; } #print "$filenameDFT\n"; else { $filenameLAY = $filename; $filenameDFT= $filename; $filenameDFT =~s/$replace/$find/; print $outfile " <a href='./$filenameLAY' class='button_l +ay'>Layout</a> <a href='./$filenameDFT' class='button_dft'> +DfT</a>\n </div>\n"; } return(@OutputButtons) }

Filename is for e.g. firstArray1.html. I use a foreach loop in other subs to go over all elements in firstArray and another to go through all elements of secondArray.

In real example filename is: file1LAY.html and file1DFT.html ... that is why I use the index, because I need a button to work for every HTML (filename). I want to make it so, that if file does not exist (but the reference is stored in one of the Buttons) it should change the reference to '#'

This is a hard challenge, but I am in despair, so atleast I can try to ask, someone might have an idea.

BR

In reply to Problem with creating Files by David92

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.