Loading ...
Sorry, an error occurred while loading the content.
 

Re: [PBML] perl question

Expand Messages
  • Paul Archer
    ... (I don t have time to go over this in detail...) ...but one obvious thing is lt is for string comparisons. You want
    Message 1 of 7 , Nov 1, 2004
      3:22pm, Luinrandir Hernsen wrote:

      >
      >
      > OK.. ignore that I', using this for a CGI
      >
      > I am trying to do a "for" loop so that %5 of $MaxNum is incremented.
      >
      > here is the NON cgi code for those who are going to freak at the "off
      > topic" question, even thought it not really....
      > Is there a better way? how would I do this with foreach?
      >
      >
      > for $v0 ($v0=0;$v0<$MaxNum;$v0+($MaxNum/20);)
      > {
      > if ($v0 lt $InCastle && $v0<$v0+($MaxNum/20) )
      (I don't have time to go over this in detail...)
      ...but one obvious thing is 'lt' is for string comparisons. You want '<='

      Paul


      > {
      > }
      > else
      > {
      > }
      > }
      >
      > and for those who can deal with it... the CGI code
      >
      > print qq|<td align=right><SELECT NAME="$ItemName">|;
      > for $v0 ($v0=0;$v0>=$MaxNum;$v0+($MaxNum/20);)
      > {
      > if ($v0 lt $InCastle && $v0+($MaxNum/20) )
      > {
      > print qq|<OPTION SELECTED>$InCastle|;
      > }
      > else
      > {
      > print qq|<OPTION>$v0|;
      > }
      > }
      > print qq|</SELECT></td>|;
      >
      > To those few who are gonna freak or be rude ....
      > yeah... i'm clueless... please keep any acidic comments to yourself.
      >
      > Lou
      >
      >
      >
      >
      >
      >
      > Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >

      ---------------------------------------------
      There are two major products that come out of
      Berkeley: LSD and UNIX. We don't believe this
      to be a coincidence. - Jeremy S. Anderson
      ---------------------------------------------
    • Jeff 'japhy' Pinyan
      ... You re not *changing* $v0 at all. for (...; ...; $v0 += $MaxNum/20) { ... Uh, use
      Message 2 of 7 , Nov 1, 2004
        On Nov 1, Luinrandir Hernsen said:

        > for $v0 ($v0=0;$v0<$MaxNum;$v0+($MaxNum/20);)

        You're not *changing* $v0 at all.

        for (...; ...; $v0 += $MaxNum/20) {

        > if ($v0 lt $InCastle && $v0<$v0+($MaxNum/20) )

        Uh, use < for numbers ALWAYS.

        --
        Jeff "japhy" Pinyan % How can we ever be the sold short or
        RPI Acacia Brother #734 % the cheated, we who for every service
        http://japhy.perlmonk.org/ % have long ago been overpaid?
        http://www.perlmonks.org/ % -- Meister Eckhart
      • Charles K. Clarkson
        ... That doesn t compile, You probably wanted to submit this. ... print qq| n|; for (my $v = 0; $v
        Message 3 of 7 , Nov 1, 2004
          Luinrandir Hernsen <Luinrandir@...> wrote:

          : I am trying to do a "for" loop so that %5 of $MaxNum is
          : incremented.
          :
          : print qq|<td align=right><SELECT NAME="$ItemName">|;
          : for $v0 ($v0=0;$v0>=$MaxNum;$v0+($MaxNum/20);)
          : { if ($v0 lt $InCastle && $v0+($MaxNum/20) )
          : { print qq|<OPTION SELECTED>$InCastle|;
          : } else
          : {
          : print qq|<OPTION>$v0|;
          : }
          : }
          : print qq|</SELECT></td>|;


          That doesn't compile, You probably wanted to submit this.

          -----------
          print qq|<td align="right"><SELECT NAME="$ItemName">\n|;
          for (my $v = 0; $v <= $MaxNum; $v += $MaxNum / 20 ) {

          if ($v < $InCastle && $v + $MaxNum / 20 ) {
          print qq|<OPTION SELECTED>$InCastle\n|;

          } else {
          print qq|<OPTION>$v\n|;
          }
          }
          print qq|</SELECT></td>|;
          -----------

          if ($v < $InCastle && $v + $MaxNum / 20 ) {

          The second condition will always test true except when
          $MaxNum equals 0, but in that case this statement wouldn't
          run so it is assumed to be unneeded.

          if ( $v < $InCastle ) {


          This solution prints more than one selected item which
          shouldn't be what you want without a MULTIPLE attribute in
          the SELECT tag. If you tell us precisely what you're trying
          to do, we could probably help you find better solutions.


          HTH,

          Charles K. Clarkson
          --
          Mobile Homes Specialist
          254 968-8328


          : here is the NON cgi code for those who are going to freak
          : at the "off topic" question, even thought it not really....
          : Is there a better way? how would I do this with foreach?

          : and for those who can deal with it... the CGI code

          : To those few who are gonna freak or be rude ....
          : yeah... i'm clueless... please keep any acidic comments to
          : yourself.

          How old are you? 10?
        • Luinrandir Hernsen
          right, thanks... I keep forgeting that... Thanks! I have change the code, after doing som eresearch, in a while command... and got it working! HooBah! Lou ...
          Message 4 of 7 , Nov 1, 2004
            right, thanks... I keep forgeting that...
            Thanks!

            I have change the code, after doing som eresearch, in a while command...
            and got it working! HooBah!

            Lou
            ----- Original Message -----
            From: Paul Archer
            To: perl-beginner@yahoogroups.com
            Sent: Monday, November 01, 2004 10:29 AM
            Subject: Re: [PBML] perl question


            3:22pm, Luinrandir Hernsen wrote:

            >
            >
            > OK.. ignore that I', using this for a CGI
            >
            > I am trying to do a "for" loop so that %5 of $MaxNum is incremented.
            >
            > here is the NON cgi code for those who are going to freak at the "off
            > topic" question, even thought it not really....
            > Is there a better way? how would I do this with foreach?
            >
            >
            > for $v0 ($v0=0;$v0<$MaxNum;$v0+($MaxNum/20);)
            > {
            > if ($v0 lt $InCastle && $v0<$v0+($MaxNum/20) )
            (I don't have time to go over this in detail...)
            ...but one obvious thing is 'lt' is for string comparisons. You want '<='

            Paul


            > {
            > }
            > else
            > {
            > }
            > }
            >
            > and for those who can deal with it... the CGI code
            >
            > print qq|<td align=right><SELECT NAME="$ItemName">|;
            > for $v0 ($v0=0;$v0>=$MaxNum;$v0+($MaxNum/20);)
            > {
            > if ($v0 lt $InCastle && $v0+($MaxNum/20) )
            > {
            > print qq|<OPTION SELECTED>$InCastle|;
            > }
            > else
            > {
            > print qq|<OPTION>$v0|;
            > }
            > }
            > print qq|</SELECT></td>|;
            >
            > To those few who are gonna freak or be rude ....
            > yeah... i'm clueless... please keep any acidic comments to yourself.
            >
            > Lou
            >
            >
            >
            >
            >
            >
            > Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html
            > Yahoo! Groups Links
            >
            >
            >
            >
            >
            >
            >

            ---------------------------------------------
            There are two major products that come out of
            Berkeley: LSD and UNIX. We don't believe this
            to be a coincidence. - Jeremy S. Anderson
            ---------------------------------------------


            Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html


            Yahoo! Groups Sponsor
            ADVERTISEMENT





            ------------------------------------------------------------------------------
            Yahoo! Groups Links

            a.. To visit your group on the web, go to:
            http://groups.yahoo.com/group/perl-beginner/

            b.. To unsubscribe from this group, send an email to:
            perl-beginner-unsubscribe@yahoogroups.com

            c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.