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

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

Expand Messages
  • Nicck_par
    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 -
    Message 1 of 6 , Jan 4, 2005
    • 0 Attachment
      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
      #ifdef UART - 8
      #ifdef FF_FAX - 7
      #ifndef CMH_CCR_C - 1
      #ifdef FF_TTY - 1
      #ifdef _SIMULATION_ - 1
      #ifdef FF_PSI - 4
      #ifdef FF_SAT_E - 1
      #ifdef WAP - 1
      #ifdef FF_TCP_IP - 9
      #ifdef AT_INTERPRETER - 4
      #ifdef SIM_TOOLKIT - 10

      file2:
      test/dl_state.c
      #ifdef FAX_AND_DATA - 19
      #ifdef UART - 8
      #ifdef FF_FAX - 7
      #ifndef CMH_CCR_C - 1
      #ifdef FF_TTY - 1
      #ifdef _SIMULATION_ - 1
      #ifdef FF_PSI - 4
      #ifdef FF_SAT_E - 1
      #ifdef WAP - 1
      #ifdef FF_TCP_IP - 9
      #ifdef AT_INTERPRETER - 4
      #ifdef SIM_TOOLKIT - 10
      #ifndef DL_STATE_C - 1
      Total:
      log:
      #ifdef FAX_AND_DATA - 19
      #ifdef UART - 8
      #ifdef FF_FAX - 7
      #ifndef CMH_CCR_C - 1
      #ifdef _SIMULATION_ - 1
      #ifdef FF_TTY - 1
      #ifdef WAP - 1
      #ifdef FF_SAT_E - 1
      #ifdef FF_PSI - 4
      #ifdef FF_TCP_IP - 9
      #ifdef AT_INTERPRETER - 4
      #ifdef SIM_TOOLKIT - 10
      #ifndef DL_STATE_C - 1

      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.
      daymobrew@... wrote:

      --- In perl-beginner@yahoogroups.com, Nicck_par <nicck_par@y...> wrote:
      > hi,
      >
      > What u have suggested to me is right..!!! I have already tried this
      and is working fine.
      >
      > But problem comes when i wan to generat a log of total occurance.
      >
      > I can expain it like this...lets say in directory dir1 there are
      three files file1.c,file2.c and file3.c.
      > now i want to find the occurance of #ifdef and #ifndef in each of
      the file separately. Thats ok.
      >
      > Also i need a total log that how many times in the whole directory i
      mean in all files...this is happening. So addition of all...!!!! How
      can i do this....!!! Is there any way that for each hash table of each
      file I can append to a new hashtable which will contain fulll details.
      >
      > Regards,
      > Nicck.
      >

      Can you type out what the desired output would look like (forget the
      code that would be involved).
      For a could of the occurances you simply have one count variable, set
      to 0 before opening the first file and incrementing every time
      ifdef/ifndef is found ($count++).
      For a file-by-file count set $hash{$file}=0 before opening the file
      and then increment for each occurance ($hash{$file}++).

      Are you looking to do something more than this?






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



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

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

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

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



      ---------------------------------
      Do you Yahoo!?
      Send holiday email and support a worthy cause. Do good.

      [Non-text portions of this message have been removed]
    • 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 2 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.