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

[PBML] Re: Regarding searchin certain occurance in number of files...!!!!

Expand Messages
  • daymobrew@yahoo.com
    ... i require...!!! ... file. for example the match found in file1 are also reapiting in file2 and also adding its own match. The log file is correct in this
    Message 1 of 6 , Jan 4, 2005
    • 0 Attachment
      --- In perl-beginner@yahoogroups.com, Nicck_par <nicck_par@y...> wrote:
      >
      > Please chekout the following output of the script which is not what
      i require...!!!
      >
      > Enter the directory name:
      > test
      >
      > file1:
      > test/cmh_ccr.c
      > #ifdef FAX_AND_DATA - 19
      > snip
      >
      > file2:
      > test/dl_state.c
      > #ifdef FAX_AND_DATA - 19
      > snip
      > Total:
      > log:
      > #ifdef FAX_AND_DATA - 19
      > snip
      >
      > If u look properly there each key and value are reapeating in each
      file. for example the match found in file1 are also reapiting in file2
      and also adding its own match. The log file is correct in this case
      ...!!! But for fie2 i need only match of itself and not all match also
      from previous file.
      >
      > I guess u understood what i want...!!!
      >
      > Bye,
      > Nicck.

      I guess the total for FAX_AND_DATA should be 20, if the dl_state.c and
      cmh_ccr.c values were correct.

      I think you need a hash of hashes. I've never implemented this (done
      hash of arrays and array of hashes).
      Use 'perldoc perldsc' or look at:
      http://aspn.activestate.com/ASPN/docs/ActivePerl/lib/Pod/perldsc.html

      Your pseudo code might be something like:
      foreach $file ( <$dir/*.c> )
      {
      my %finds;
      open $file
      if ifdef/ifndef found
      {
      # Might have to check 'if defined $finds{$line}' first.
      $finds{$line}++
      $HoH{$all}{$line}++ # For total.
      }
      close $file
      $HoH{$group} = { %finds };
      }

      See the perldsc doc for how to access the keys for later printing.
    Your message has been successfully submitted and would be delivered to recipients shortly.