Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    9
    Rep Power
    0

    Moving perl code from one section to another...


    First off, I want to say I'm an extreme newb at this, so I hope I explain this well enough.

    I have some website perl code and am trying to redesign it a bit. I have knowledge of HTML so the redesign is going rather well, but I have run into a road block. I have code in one section of the site that I want to move into another section so it display's near the top of the web page rather than the bottom. Also, I'm trying to put the code within an HTML table (I'm thinking this is the problem as the code is not in a table already, it creates one). Also, there are if statements involved with this code.

    When I move the code into the table, I get Global Symbol errors that state "requires explicit package at line etc"

    Can anyone offer any assistance on how to move this code so I won't get the error. If you need to see the code, let me know and I can paste it in another post.

    Any help is GREATLY appreciated!

    Joven
  2. #2
  3. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,264
    Rep Power
    1810
    Very difficult to help without the code; so yes, you'll need to post it.

    I'm just guessing that by reordering you are trying to use variables that weren't declared yet. The problems are probably not too hard to fix.

    Very likely though that the better way to handle your script would be with some sort of template system, so that your code and your presentation are separated. That would make it much easier for you to redesign the appearance without breaking the script, but that sort of effort might be more than you want to address right now.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    9
    Rep Power
    0
    Originally Posted by keath
    Very difficult to help without the code; so yes, you'll need to post it.

    I'm just guessing that by reordering you are trying to use variables that weren't declared yet. The problems are probably not too hard to fix.

    Very likely though that the better way to handle your script would be with some sort of template system, so that your code and your presentation are separated. That would make it much easier for you to redesign the appearance without breaking the script, but that sort of effort might be more than you want to address right now.
    Here's the script:

    }

    if (($config{'buyitnow'} eq 'yes') && ($buyit > '0') && ($#bids eq '0') && ($dutch eq 'no') && ($reserve <= '0')) {
    print <<"EOF";
    <p>
    <div align="center">
    <table align="center" border="0" width="30%" cellpadding="0" cellspacing="0">
    <tr>
    <td align="center" bgcolor="#000000"><a HREF="$config{'scripturl'}?action=buyit&CATEGORY=$form{'category'}&ITEM=$form{'item'}">Buy It</a> for $currency$buyit<br>This option disappears once a bid is placed.</td>
    </tr>
    </table>
    </div>
    EOF
    }
    if (($config{'buyitnow'} eq 'yes') && ($buyit > '0') && ($dutch eq 'no') && ($reserve > '0') && ($reserve > "$chklastbid")) {
    print <<"EOF";
    <p>
    <div align="center">
    <table border="0" width="35%" cellpadding="0" cellspacing="0">
    <tr>
    <td bgcolor="#000000"><a HREF="$config{'scripturl'}?action=buyit&CATEGORY=$form{'category'}&ITEM=$form{'item'}">Buy It</a> for $currency$buyit<BR>This option disappears once the reserve price has been met.</td>
    </tr>
    </table>
    </div>
    EOF
    }


    Also, I may not have posted all of it, so if I'm missing some variables, please let me know.

    This code is near the middle of the web page. I'm only moving it to a section just above it. The variables for this code are created from a different web page. Also, I don't see on the code above it where variables are created prior to this code.

    I want to move it so it puts the results in a table I've created with some other information near the top of the page.

    Does this make sense?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Location
    Paris area, France
    Posts
    842
    Rep Power
    496
    Hum, a script starting with a closing brace (closing curly bracket) does not seem to be right. You must have omitted something at the beginning.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    9
    Rep Power
    0
    Well, there is code above it, but I wasn't 100% sure if the } was a part of the code I'm trying to move. I tried moving the code without the } and just starting with the "if" statement and ending with the } at the bottom and got the same kind of error.

    There is this code after it though:

    print <<"EOF";
    </font>

    Would this matter?
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    9
    Rep Power
    0
    Well, I've made some leeway with the code I'm trying to move around and have made a small discovery. The code I'm moving:

    if (($config{'buyitnow'} eq 'yes') && ($buyit > '0') && ($#bids eq '0') && ($dutch eq 'no') && ($reserve <= '0')) {
    print <<"EOF";
    <p>
    <div align="center">
    <table align="center" border="0" width="30%" cellpadding="0" cellspacing="0">
    <tr>
    <td align="center" bgcolor="#000000"><a HREF="$config{'scripturl'}?action=buyit&CATEGORY=$form{'category'}&ITEM=$form{'item'}">Buy It</a> for $currency$buyit<br>This option disappears once a bid is placed.</td>
    </tr>
    </table>
    </div>
    EOF
    }
    if (($config{'buyitnow'} eq 'yes') && ($buyit > '0') && ($dutch eq 'no') && ($reserve > '0') && ($reserve > "$chklastbid")) {
    print <<"EOF";
    <p>
    <div align="center">
    <table border="0" width="35%" cellpadding="0" cellspacing="0">
    <tr>
    <td bgcolor="#000000"><a HREF="$config{'scripturl'}?action=buyit&CATEGORY=$form{'category'}&ITEM=$form{'item'}">Buy It</a> for $currency$buyit<BR>This option disappears once the reserve price has been met.</td>
    </tr>
    </table>
    </div>
    EOF
    }

    print <<"EOF";

    only works if I move it any where else on the webpage. But the moment I put this code into the HTML table, I get errors.

    Why is this?
  12. #7
  13. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,264
    Rep Power
    1810
    But the moment I put this code into the HTML table, I get errors.
    What do you mean by this? Why don't you give us the surrounding context?
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    9
    Rep Power
    0
    Originally Posted by keath
    What do you mean by this? Why don't you give us the surrounding context?
    This is the HTML table that I have set up:

    <div align="center">
    <table align="center" width="85%" border="0" cellspacing="0">
    <tr>
    <th valign="top" rowspan="23" scope="col"><a name="IMG"><img name="large" SRC="$image1" border="1"></th>
    <th align="left" colspan="5" scope="col"><font size="6"><b>$title</b></font></th>
    </tr>
    <tr>
    <td width="10%" align="right" valign="top">Item Condition:</td>
    <td width="30%" valign="top"><b>$condition</b></td>
    <td width=1%></td>
    <td width="25%"></td>
    <td width="2%"></td>
    </tr>
    <tr>
    <td align="right" valign="top">Time Left:</td>
    <td valign="top"><b>$timeremain</b><BR>
    <font size="2"><B>Ends: </b>$closetime</font></td>
    <td></td>
    <td></td>
    <td></td>
    </tr>
    <tr>
    <td></td>
    <td></td>
    <td></td>
    <td style="border: 3px solid; border-color:#9900FF;" bgcolor="e5e5e5"><font color="#9900CC" size="5"><b>Seller Information</B></font></td>
    <td></td>
    </tr>
    <tr>
    <td style="border-bottom: 3px solid; border-color:#9900FF" align="right" valign="top">Dutch Auction:</td>
    <td style="border-bottom: 3px solid; border-color:#9900FF" valign="top"><b>$dutch</b></td>
    <td></td>
    <td style="border-left: 3px solid; border-right: 3px solid; border-color:#9900FF" bgcolor="#F2F2F2"><span class="style3"><b>$selleralias</b> <a HREF="$config{'scripturl'}?action=viewrate&ALIAS=$selleralias&ITEM=$form{'item'}">( $sellerrating ) $star1s $star2s $star3s $star4s $star5s</a></span></td>
    <td></td>
    </tr>
    <tr>
    <td valign="top"></td>
    <td valign="top"></td>
    <td></td>
    <td style="border-left: 3px solid; border-right: 3px solid; border-color:#9900FF" bgcolor="#F2F2F2"><span class="style3">$sellerrating Positive Feedback</span></td>
    <td></td>
    </tr>
    <tr>
    <td align="right" valign="top">Current Bid: </td>
    <td valign="middle"><b><font size="5" color="Green">$currency$lastbid</font> ($numbids)</b> $bidhistory<BR>$reservemsg</td>
    <td></td>
    <td style="border-left: 3px solid; border-right: 3px solid; border-color:#9900FF" bgcolor="#F2F2F2"><P><span class="style2"><span class="style3"></span></span></td>
    <td></td>
    </tr>
    <tr>
    <td align="right" valign="top">&nbsp;</td>
    <td valign="top">&nbsp;</td>
    <td></td>
    <td style="border-left: 3px solid; border-right: 3px solid; border-color:#9900FF" bgcolor="#F2F2F2"><a HREF="$config{'scripturl'}?action=askquestion&category=$form{'category'}&item=$form{'item'}" class="style3">Ask question or view Q&A ( $qacount )</a></td>
    <td></td>
    </tr>
    <tr>
    <td colspan="2" align="center" valign="top">Buy It Now Code</td>
    <td></td>
    <td style="border-left: 3px solid; border-right: 3px solid; border-color:#9900FF" bgcolor="#F2F2F2"><span class="style3"><a href="$config{'scripturl'}?action=search&searchtype=viewother&searchstring=$selleralias">$selleralia s 's other auctions</a> $sellerpage $sellersstore</span></td>
    <td></td>
    </tr>
    <tr>
    <td valign="top"></td>
    <td valign="top"></td>
    <td></td>
    <td style="border-left: 3px solid; border-right: 3px solid; border-color:#9900FF" bgcolor="#F2F2F2"><a href="$config{'scripturl'}?action=mailto&category=$form{'category'}&item=$form{'item'}" class="style3">Email this to a friend</a></td>
    <td></td>
    </tr>
    <tr>
    <td valign="top">bid button</td>
    <td valign="top">Your Bid Field}</td>
    <td></td>
    <td style="border-left: 3px solid; border-right: 3px solid; border-color:#9900FF" bgcolor="#F2F2F2"><P><span class="style2"><span class="style3"></span></span></td>
    <td></td>
    </tr>
    <tr>
    <td align="left" valign="top" colspan="2"><font size="2">Enter lowest bid or more in bid inc increments</font></td>
    <td></td>
    <td style="border-left: 3px solid; border-right: 3px solid; border-color:#9900FF" bgcolor="#F2F2F2"><span class="style3">Buyer</span></td>
    <td></td>
    </tr>
    <tr>
    <td align="left" valign="top" colspan="2"><font size="2">Registered user required to bid.</font></td>
    <td></td>
    <td style="border-left: 3px solid; border-right: 3px solid; border-color:#9900FF" bgcolor="#F2F2F2"><span class="style3">Retract Bid</span></td>
    <td></td>
    </tr>
    <tr>
    <td align="right" valign="top">User Name:</td>
    <td valign="top">user name field</td>
    <td></td>
    <td style="border-left: 3px solid; border-right: 3px solid; border-color:#9900FF" bgcolor="#F2F2F2"><P><span class="style2"><span class="style3"></span></span></td>
    <td></td>
    </tr>
    <tr>
    <td align="right" valign="top">Password:</td>
    <td valign="top">password field</td>
    <td></td>
    <td style="border-left: 3px solid; border-right: 3px solid; border-color:#9900FF" bgcolor="#F2F2F2"><span class="style3">Seller</span></td>
    <td></td>
    </tr>
    <tr>
    <td style="border-bottom: 3px solid; border-color:#9900FF"><p></td>
    <td style="border-bottom: 3px solid; border-color:#9900FF"><p></td>
    <td></td>
    <td style="border-left: 3px solid; border-right: 3px solid; border-color:#9900FF" bgcolor="#F2F2F2"><span class="style3">Ban a Bidder</span></td>
    <td></td>
    </tr>
    <tr>
    <td align="right" valign="top">Shipping:</td>
    <td valign="top">$currency$shippfee1 via $shippservice1</td>
    <td></td>
    <td style="border-left: 3px solid; border-right: 3px solid; border-color:#9900FF" bgcolor="#F2F2F2"><a HREF="$config{'scripturl'}?action=sellerlogon&category=$form{'category'}&item=$form{'item'}" class="style3">Edit item if no bids placed</a></td>
    <td></td>
    </tr>
    <tr>
    <td valign="top"></td>
    <td valign="top"><font size="2">Item Location: <b>$location</b></font></td>
    <td></td>
    <td style="border-left: 3px solid; border-right: 3px solid; border-color:#9900FF" bgcolor="#f2f2f2"><P><span class="style3"></span></td>
    <td></td>
    </tr>
    <tr>
    <td valign="top"></td>
    <td valign"Top"><font size="2">Ships to: <b>$shipsto</b></font></td>
    <td></td>
    <td style="border-left: 3px solid; border-right: 3px solid; border-color:#9900FF" bgcolor="#f2f2f2"><P><span class="style3"></span></td>
    <td></td>
    </tr>
    <tr>
    <td></td>
    <td></td>
    <td></td>
    <td style="border-left: 3px solid; border-right: 3px solid; border-color:#9900FF" bgcolor="#f2f2f2"></td>
    <td></td>
    </tr>
    <tr>
    <td align="right" valign="top">Payments:</td>
    <td valign="top">$pay <a href="#PAYMENTACCEPTED">(See Details)</a></td>
    <td></td>
    <td style="border-left: 3px solid; border-right: 3px solid; border-bottom: 3px solid; border-color:#9900FF" bgcolor="#f2f2f2"><P><span class="style3"></span></td>
    <td></td>
    </tr>
    <tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    </tr>
    <tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    </tr>
    </table>
    </div>
    EOF

    Basically, the code I want to paste into this table goes in the area that says "Buy it now code". When I have the code pasted on the page above this table, it displays just fine, but when it goes into the HTML table code, I get all sorts of Global Symbol errors...

    Does this help?
  16. #9
  17. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,264
    Rep Power
    1810
    No it doesn't.

    Perl isn't PHP. An HTML file isn't going to be interpreted as a perl script that's going to be executed, so I don't even know how you are receiving the error message.

    Is this file a .cgi file? Does it start with the line #/usr/bin/perl?

    You can't just dump a bunch of HTML in a perl script and expect that it will run. If you notice in your two 'if' statements, there is HTML output. But both of those are perl strings created using a HERE doc type of string creation.

    Not trying to seem harsh, I just don't really see the context for this working, although it's possible you are assuming we can imagine the code surrounding this.
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    9
    Rep Power
    0
    Originally Posted by keath
    No it doesn't.

    Perl isn't PHP. An HTML file isn't going to be interpreted as a perl script that's going to be executed, so I don't even know how you are receiving the error message.

    Is this file a .cgi file? Does it start with the line #/usr/bin/perl?

    You can't just dump a bunch of HTML in a perl script and expect that it will run. If you notice in your two 'if' statements, there is HTML output. But both of those are perl strings created using a HERE doc type of string creation.

    Not trying to seem harsh, I just don't really see the context for this working, although it's possible you are assuming we can imagine the code surrounding this.
    Well, is there a way to upload a file for everyone to see. I've tried to copy the code around the area that I'm trying to move, however I now believe that you may need to see the whole .pl file in order to understand what I'm trying to do.

    Would that help?
  20. #11
  21. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,264
    Rep Power
    1810
    Sure, let's see the whole thing.

    Below the reply area is a section called "Additional Options" that may allow you to attach a file. Sometimes there are restrictions for new users. Not sure if you can use that or not yet.
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2005
    Posts
    22
    Rep Power
    0
    I'm trying to make contribution to this thread but i'm struggling. For two reasons

    1. I dont really understand you code, it is totally unindent coded and ugly to read. Where are the code tags?
    2. You haven't exampled properly has to what your trying to achive. Absolute vague.

    ssharish2005
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    9
    Rep Power
    0
    Originally Posted by ssharish2005
    I'm trying to make contribution to this thread but i'm struggling. For two reasons

    1. I dont really understand you code, it is totally unindent coded and ugly to read. Where are the code tags?
    2. You haven't exampled properly has to what your trying to achive. Absolute vague.

    ssharish2005
    Well, what I've copied is only a sliver of the actual file I have. I wasn't sure if you needed the whole file or could go off what I copied. It's evident you'll need the whole file. Unfortunately I cannot upload a file since I am new as I don't have the option in the additional options section to do so.

    Not sure what to do at this point...
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Apr 2009
    Posts
    1,954
    Rep Power
    1225
    Post your code on pastebin and post that link here.
  28. #15
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    9
    Rep Power
    0
    Originally Posted by FishMonger
    Post your code on pastebin and post that link here.
    Paste Bin Link

    Here's the link to the entire code. I hope this helps...
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo