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

Re: [PBML] Can anyone explain this code?

Expand Messages
  • Charles K. Clarkson
    bpaea ... This looks at the contents of $line: /^ beginning of the line s* 0 or more whitespace characters (
    Message 1 of 1 , Jan 30, 2002
    • 0 Attachment
      "bpaea" <dav@...>

      : I am trouble shooting a script that does a ps -eo command and kills a
      : process if it meets certain criteria and came upon these lines. Can
      : anyone explain what each line does? I know if the variable meets
      : this condition it goes to next line. The variables I get from doing
      : a ps -eo and is either the elapses time or cpu time.
      :
      : if ($line =~ /^\s*(\S+)\s+(\S+)\s+(\S+)/)

      This looks at the contents of $line:
      /^ beginning of the line
      \s* 0 or more whitespace characters
      ( $1 place holder
      \S+ 1 or more non-whitespace characters
      )
      \s+ 1 or more whitespace characters
      ( $2 place holder
      \S+ 1 or more non-whitespace characters
      )
      \s+ 1 or more whitespace characters
      ( $3 place holder
      \S+ 1 or more non-whitespace characters
      )
      /

      If $line starts with:
      1 2 3

      Then $1 = '1', $2 = '2', & $3 = '3'

      : ($eltime =~ /^(\d+)-/) { $eldays = $1; }

      This is not syntatically complete. I assume it is suppose to be
      if ($eltime =~ /^(\d+)-/) { $eldays = $1; }

      If $eltime begins with 1 or more digits followed by a dash,
      place the digits in $1.


      : if ($cputime =~ /^\d+-/) { $cpumin = 1440; }

      Same as above. This one doesn't store anything since the
      regex doesn't use parenthesis.( )

      : # elsif ($cputime =~ /^(\d+):(\d+):\d+/)

      This is a comment. It doesn't do anything. If it were
      uncommented it would take a string like:

      10:20:0000 and assign $1 = 10 and $2 = 20.

      HTH,
      Charles K. Clarkson
      Clarkson Energy Homes, Inc.
      254 968-8328


      Do or do not, there is no try - Yoda
    Your message has been successfully submitted and would be delivered to recipients shortly.