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

Re: [PBML] How come this for loop makes an infinite loop?

Expand Messages
  • Jabir Ahmed
    Syntax error in for loop for($loop = 0; $loop != $input, $loop = $loop + 1; ) == old for($loop = 0; $loop != $input; $loop = $loop + 1)= new
    Message 1 of 8 , Dec 20, 2006
    • 0 Attachment
      Syntax error in for loop


      for($loop = 0; $loop != $input, $loop = $loop + 1; ) ==> old


      for($loop = 0; $loop != $input; $loop = $loop + 1)=>new

      lord_vodka_ccccccxxxxxxvi <lord_vodka_ccccccxxxxxxvi@...> wrote:
      print "Input ";
      $input = <STDIN>;
      chomp($input);
      print newline; print newline;
      @TONE_ROW = (1,2,3,4,5,6,7,8,9,10,11,12);
      print @TONE_ROW;
      print newline; print newline;
      print newline; print newline;

      for($loop = 0; $loop != $input, $loop = $loop + 1; )
      {
      print "@TONE_ROW\n\n";
      push(@TONE_ROW, shift(@TONE_ROW));
      }






      Phone (mobile) : +91-98861 36420
      E-Mail: jabirahmed@..., jabirahmed@...
      --
      "a single
      conversation across the table with a wise man is worth a month's study of books."
      ---
      __________________________________________________
      Do You Yahoo!?
      Tired of spam? Yahoo! Mail has the best spam protection around
      http://mail.yahoo.com

      [Non-text portions of this message have been removed]
    • merlyn@stonehenge.com
      ... lord print Input ; lord $input = ; lord chomp($input); lord print newline; print newline; I don t know what these are supposed to do.
      Message 2 of 8 , Dec 20, 2006
      • 0 Attachment
        >>>>> "lord" == lord vodka ccccccxxxxxxvi <lord_vodka_ccccccxxxxxxvi@...> writes:

        lord> print "Input ";
        lord> $input = <STDIN>;
        lord> chomp($input);
        lord> print newline; print newline;

        I don't know what these are supposed to do. "newline" means nothing
        to Perl.

        lord> @TONE_ROW = (1,2,3,4,5,6,7,8,9,10,11,12);
        lord> print @TONE_ROW;
        lord> print newline; print newline;
        lord> print newline; print newline;

        lord> for($loop = 0; $loop != $input, $loop = $loop + 1; )

        Your test is testing if $loop = $loop + 1 returns false. Given
        that $loop starts at 0, this is an infinite loop.

        lord> {
        lord> print "@TONE_ROW\n\n";
        lord> push(@TONE_ROW, shift(@TONE_ROW));
        lord> }

        --
        Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
        <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
        Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
        See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
      • San-Pablo, Arnel
        Hi Guys, Would anyone in the group know any PERL command line to trigger the enter bar on the keyboard. I have a script which has a line that executes
        Message 3 of 8 , Dec 21, 2006
        • 0 Attachment
          Hi Guys,

          Would anyone in the group know any PERL command line to trigger the
          "enter" bar on the keyboard.

          I have a script which has a line that executes another PERL-CGI
          script,this CGI script outputs a graphical

          display,causing my script to hang, you can continue only the remaining
          lines of the script when you press

          the "enter" bar to make the graphical display disappear and continue
          with the succeeding lines of d script.

          If anyone knows the solution , please do tell me , spent days looking
          for this in the net already.

          Thanks in advance.

          Merry Xmas!
          Arnel





          [Non-text portions of this message have been removed]
        • saiju joseph
          The condition for loop termintion $loop != $input will happen only if a positive integer is entered as $input. ... Send free SMS to your Friends on Mobile from
          Message 4 of 8 , Dec 21, 2006
          • 0 Attachment
            The condition for loop termintion $loop != $input will
            happen only if a positive integer is entered as
            $input.

            --- lord_vodka_ccccccxxxxxxvi
            <lord_vodka_ccccccxxxxxxvi@...> wrote:

            >
            > print "Input ";
            > $input = <STDIN>;
            > chomp($input);
            > print newline; print newline;
            > @TONE_ROW = (1,2,3,4,5,6,7,8,9,10,11,12);
            > print @TONE_ROW;
            > print newline; print newline;
            > print newline; print newline;
            >
            > for($loop = 0; $loop != $input, $loop = $loop + 1; )
            > {
            > print "@TONE_ROW\n\n";
            > push(@TONE_ROW, shift(@TONE_ROW));
            > }
            >
            >


            Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php
          • senthilk_friend
            Hi, I would like to extract a some word from log file and export the those words as a CSV file. Can any one help me on this. E.g) i need to extract the time
            Message 5 of 8 , Jan 1, 2007
            • 0 Attachment
              Hi,
              I would like to extract a some word from log file and export the
              those words as a CSV file.
              Can any one help me on this.

              E.g)
              i need to extract the time stamp (14:57:37), the word CPU and
              Current value 8%.

              Below is the sample log file .
              Kindly help me on this
              kumar


              B3692A GlancePlus C.03.86.00 14:57:37 swqapd02 9000/800
              Current Avg High
              ---------------------------------------------------------------------
              ----------
              CPU Util SUU |
              8% 8% 8%
              Disk Util FFFF |
              8% 8% 8%

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

              PROCESS LIST
              User CPU Util Cum
              Disk Thd
              Process Name PID PPID Pri Name ( 400% max) CPU IO Rate
              RSS Cnt
              ---------------------------------------------------------------------
              -----------
              oracleUBOM 339 1 154 oraubom 9.5/ 0.0 4.9 0.0/ 0.0
              40.8mb 1

              B3692A GlancePlus C.03.86.00 14:57:37 swqapd02 9000/800
              Current Avg High
              ---------------------------------------------------------------------
              ----------
              CPU Util SUU |
              8% 8% 8%
              Disk Util FFFF |
              8% 8% 8%

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

              PROCESS LIST
              User CPU Util Cum
              Disk Thd
              Process Name PID PPID Pri Name ( 400% max) CPU IO Rate
              RSS Cnt
              ---------------------------------------------------------------------
              -----------
              oracleUBOM 339 1 154 oraubom 9.5/ 0.0 4.9 0.0/ 0.0
              40.8mb 1
            • Dave Gray
              ... perl -ne if (/( d+: d+: d+)/) { $ts = $1 } elsif (/ bCPU b/) { $flag = 1 } elsif ($flag) { ($pct) = $_ =~ /( d+%)/; print [$ts] CPU $pct n ; $flag = 0 }
              Message 6 of 8 , Jan 2, 2007
              • 0 Attachment
                On 1/1/07, senthilk_friend <senthilk_friend@...> wrote:
                > I would like to extract a some word from log file and export the
                > those words as a CSV file.
                > Can any one help me on this.
                >
                > E.g)
                > i need to extract the time stamp (14:57:37), the word CPU and
                > Current value 8%.
                >
                > Below is the sample log file .
                > Kindly help me on this
                > kumar

                perl -ne 'if (/(\d+:\d+:\d+)/) { $ts = $1 } elsif (/\bCPU\b/) { $flag
                = 1 } elsif ($flag) { ($pct) = $_ =~ /(\d+%)/; print "[$ts] CPU
                $pct\n"; $flag = 0 }' sample_log_file

                > B3692A GlancePlus C.03.86.00 14:57:37 swqapd02 9000/800
                > Current Avg High
                > ----------------------------------------------------------
                > ----------
                > CPU Util SUU |
                > 8% 8% 8%
                > Disk Util FFFF |
                > 8% 8% 8%
                >
                > ----------------------------------------------------------
                > ----------
                >
                > PROCESS LIST
                > User CPU Util Cum
                > Disk Thd
                > Process Name PID PPID Pri Name ( 400% max) CPU IO Rate
                > RSS Cnt
                > ----------------------------------------------------------
                > -----------
                > oracleUBOM 339 1 154 oraubom 9.5/ 0.0 4.9 0.0/ 0.0
                > 40.8mb 1
                >
                > B3692A GlancePlus C.03.86.00 14:57:37 swqapd02 9000/800
                > Current Avg High
                > ----------------------------------------------------------
                > ----------
                > CPU Util SUU |
                > 8% 8% 8%
                > Disk Util FFFF |
                > 8% 8% 8%
                >
                > ----------------------------------------------------------
                > ----------
                >
                > PROCESS LIST
                > User CPU Util Cum
                > Disk Thd
                > Process Name PID PPID Pri Name ( 400% max) CPU IO Rate
                > RSS Cnt
                > ----------------------------------------------------------
                > -----------
                > oracleUBOM 339 1 154 oraubom 9.5/ 0.0 4.9 0.0/ 0.0
                > 40.8mb 1
                >
                >
              • Dave Gray
                ... What have you tried? What isn t working about that? Do you know what CSV format is? You can modify what I sent below very simply to transform it into CSV
                Message 7 of 8 , Jan 3, 2007
                • 0 Attachment
                  On 1/3/07, sendilk_kumar <sendilk_kumar@...> wrote:
                  > Thanks very much. Please let me know how ot export the data in to
                  > CSV file.

                  What have you tried? What isn't working about that? Do you know what
                  CSV format is? You can modify what I sent below very simply to
                  transform it into CSV based on what the requirements are for this data
                  when you want to use it again. That is left as an exercise for the
                  reader.

                  > -- In perl-beginner@yahoogroups.com, "Dave Gray" <yargevad@...>
                  > wrote:
                  > >
                  > > On 1/1/07, senthilk_friend <senthilk_friend@...> wrote:
                  > > > I would like to extract a some word from log file and export
                  > the
                  > > > those words as a CSV file.
                  > > > Can any one help me on this.
                  > > >
                  > > > E.g)
                  > > > i need to extract the time stamp (14:57:37), the word CPU and
                  > > > Current value 8%.
                  > > >
                  > > > Below is the sample log file .
                  > > > Kindly help me on this
                  > > > kumar
                  > >
                  > > perl -ne 'if (/(\d+:\d+:\d+)/) { $ts = $1 } elsif (/\bCPU\b/) {
                  > $flag
                  > > = 1 } elsif ($flag) { ($pct) = $_ =~ /(\d+%)/; print "[$ts] CPU
                  > > $pct\n"; $flag = 0 }' sample_log_file
                  > >
                  > > > B3692A GlancePlus C.03.86.00 14:57:37 swqapd02 9000/800
                  > > > Current Avg High
                  > > > ----------------------------------------------------------
                  > > > ----------
                  > > > CPU Util SUU |
                  > > > 8% 8% 8%
                  > > > Disk Util FFFF |
                  > > > 8% 8% 8%
                  > > >
                  > > > ----------------------------------------------------------
                  > > > ----------
                  > > >
                  > > > PROCESS LIST
                  > > > User CPU Util Cum
                  > > > Disk Thd
                  > > > Process Name PID PPID Pri Name ( 400% max) CPU IO
                  > Rate
                  > > > RSS Cnt
                  > > > ----------------------------------------------------------
                  > > > -----------
                  > > > oracleUBOM 339 1 154 oraubom 9.5/ 0.0 4.9 0.0/
                  > 0.0
                  > > > 40.8mb 1
                  > > >
                  > > > B3692A GlancePlus C.03.86.00 14:57:37 swqapd02 9000/800
                  > > > Current Avg High
                  > > > ----------------------------------------------------------
                  > > > ----------
                  > > > CPU Util SUU |
                  > > > 8% 8% 8%
                  > > > Disk Util FFFF |
                  > > > 8% 8% 8%
                  > > >
                  > > > ----------------------------------------------------------
                  > > > ----------
                  > > >
                  > > > PROCESS LIST
                  > > > User CPU Util Cum
                  > > > Disk Thd
                  > > > Process Name PID PPID Pri Name ( 400% max) CPU IO
                  > Rate
                  > > > RSS Cnt
                  > > > ----------------------------------------------------------
                  > > > -----------
                  > > > oracleUBOM 339 1 154 oraubom 9.5/ 0.0 4.9 0.0/
                  > 0.0
                  > > > 40.8mb 1
                  > > >
                  > > >
                  > >
                  >
                  >
                  >
                Your message has been successfully submitted and would be delivered to recipients shortly.