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

25935Eval and memory problems

Expand Messages
  • computerdribble
    Jan 8, 2008
    • 0 Attachment
      Greetings all...

      I used references found elsewhere to create a script to analyze log
      files for specific things.

      The "specific things" are stored in a mysql database as a regex expression
      Example:

      ( ( $field =~ /blah/) and ($field =~ /that/) )

      I need the regex expressions in a database to tweaking and allowing
      others to maintain who do not know or who are as green as I am to Perl.

      I open the MySql database, no problem, load the contents into arrays,
      no problem.

      Open the log file (approx 1.48megs in size) for reading only.

      Ok, in the program ( I can;t post it as it stands)


      I have a logic loop

      grab a line from the log file

      run all regex expressions against the log line grabbed. This could be
      from 1 to 500 different tests.


      its done in a EVAL statement.

      similar to:

      if ( eval $array[$vartoarraycontents] )
      {
      ## if found.. do this

      ## do this: store information on line found and
      ## what found when compared to a rule/regex expression
      ## to be sent as an email to me

      }

      ## send email.



      that's about it.

      It runs perfectly for small log files (under 500k in size)
      BUT on the larger log files... EVAL blows out with a memory exhausted
      error. I am chaulking this up to the problem of memory leakage on the
      EVAL function.


      I am wondering IF there are any other ways to EVAL something prior to
      doing a comparision?

      I tried;

      if ( eval { $array[$pointer] } )


      and it throws back a hex code to me when I debug the EVAL contents.
      (stored to a variable for debugging)

      I am assuming that it throws me back a HASH of the test, but I can;t
      figure out how to use that information.

      I also tried to store the eval { $array[ $pointer] } to a variable
      and it ONLY shows the contents of the array based upon the pointer!
      <scratches head>



      So my main question, is is there an alternative to the EVAL


      I'm using perl 5.8.1


      thanks in advance!

      Joe.
    • Show all 15 messages in this topic