use strict;
use File::Spec::Functions;
#copyright John Scoles Oct 31 2010 (Booooo!)
# orgianl little search thingy Tim Procter.

my $search_recursive = 1;
my $search_content = 1;

my @pl_words =('Argv'
,'Cmd'
,'DBcv'
,'DBgv'
,'DBline'
,'DBsignal'
,'DBsingle'
,'DBsub'
,'DBtrace'
,'Dir'
,'Env'
,'LIO'
,'Mem'
,'MemParse'
,'MemShared'
,'OpPtr'
,'OpSlab'
,'OpSpace'
,'Proc'
,'Sock'
,'StdIO'
,'Sv'
,'Xpv'
,'amagic_generation'
,'an'
,'apiversion'
,'argvgv'
,'argvout_stack'
,'argvoutgv'
,'basetime'
,'beginav'
,'beginav_save'
,'blockhooks'
,'body_arenas'
,'body_roots'
,'bodytarget'
,'breakable_sub_gen'
,'checkav'
,'checkav_save'
,'chopset'
,'clocktick'
,'collation_ix'
,'collation_name'
,'collation_standard'
,'collxfrm_base'
,'collxfrm_mult'
,'colors'
,'colorset'
,'compcv'
,'compiling'
,'comppad'
,'comppad_name'
,'comppad_name_fill'
,'comppad_name_floor'
,'cop_seqmax'
,'cryptseen'
,'curcop'
,'curcopdb'
,'curpad'
,'curpm'
,'curstack'
,'curstackinfo'
,'curstash'
,'curstname'
,'custom_op_descs'
,'custom_op_names'
,'cv_has_eval'
,'dbargs'
,'debstash'
,'debug'
,'debug_pad'
,'def_layerlist'
,'defgv'
,'defoutgv'
,'defstash'
,'delaymagic'
,'destroyhook'
,'diehook'
,'dirty'
,'doextract'
,'doswitches'
,'dowarn'
,'dumper_fd'
,'dumpindent'
,'e_script'
,'efloatbuf'
,'efloatsize'
,'egid'
,'encoding'
,'endav'
,'envgv'
,'errgv'
,'errors'
,'euid'
,'eval_root'
,'eval_start'
,'evalseq'
,'exit_flags'
,'exitlist'
,'exitlistlen'
,'fdpid'
,'filemode'
,'firstgv'
,'forkprocess'
,'formfeed'
,'formtarget'
,'generation'
,'gensym'
,'gid'
,'glob_index'
,'globalstash'
,'hash_seed'
,'hintgv'
,'hints'
,'hv_fetch_ent_mh'
,'in_clean_all'
,'in_clean_objs'
,'in_eval'
,'in_load_module'
,'incgv'
,'initav'
,'inplace'
,'isarev'
,'known_layers'
,'last_in_gv'
,'last_swash_hv'
,'last_swash_key'
,'last_swash_klen'
,'last_swash_slen'
,'last_swash_tmps'
,'lastfd'
,'lastgotoprobe'
,'lastscream'
,'laststatval'
,'laststype'
,'localizing'
,'localpatches'
,'lockhook'
,'madskills'
,'main_cv'
,'main_root'
,'main_start'
,'mainstack'
,'markstack'
,'markstack_max'
,'markstack_ptr','max_intro_pending','maxo','maxscream','maxsysfd','memory_debug_header','mess_sv','min_intro_pending','minus_E','minus_F','minus_a','minus_c','minus_l','minus_n','minus_p','modcount','modglobal','my_cxt_keys','my_cxt_list','my_cxt_size','na','nomemok','numeric_local','numeric_name','numeric_radix_sv','numeric_standard','ofsgv','oldname','op','op_mask','opfreehook','opsave','origalen','origargc','origargv','origenviron','origfilename','ors_sv','osname','pad_reset_pending','padix','padix_floor','parser','patchlevel','peepp','perl_destruct_level','perldb','perlio','pidstatus','ppid','preambleav','profiledata','psig_name','psig_pend','psig_ptr','ptr_table','reentrant_buffer','reentrant_retint','reg_state','regdummy','regex_pad','regex_padav','reginterp_cnt','registered_mros','regmatch_slab','regmatch_state','rehash_seed','rehash_seed_set','replgv','restartjmpenv','restartop','rpeepp','rs','runops','savebegin','savestack','savestack_ix','savestack_max','sawampersand','scopestack','scopestack_ix','scopestack_max','scopestack_name','screamfirst','screamnext','secondgv','sharehook','sig_pending','sighandlerp','signalhook','signals','slab_count','slabs','sort_RealCmp','sortcop','sortstash','splitstr','srand_called','stack_base','stack_max','stack_sp','start_env','stashcache','statbuf','statcache','statgv','statname','statusvalue','statusvalue_posix','statusvalue_vms','stderrgv','stdingv','strtab','sub_generation','subline','subname','sv_arenaroot','sv_count','sv_no','sv_objcount','sv_root','sv_serial','sv_undef','sv_yes','sys_intern','taint_warn','tainted','tainting','threadhook','timesbuf','tmps_floor','tmps_ix','tmps_max','tmps_stack','top_env','toptarget','uid','unicode','unitcheckav','unitcheckav_save','unlockhook','unsafe','utf8_X_L','utf8_X_LV','utf8_X_LVT','utf8_X_LV_LVT_V','utf8_X_T','utf8_X_V','utf8_X_begin','utf8_X_extend','utf8_X_non_hangul','utf8_X_prepend','utf8_alnum','utf8_alpha','utf8_ascii','utf8_cntrl','utf8_digit','utf8_graph','utf8_idcont','utf8_idstart','utf8_lower','utf8_mark','utf8_perl_space','utf8_perl_word','utf8_posix_digit','utf8_print','utf8_punct','utf8_space','utf8_tofold','utf8_tolower','utf8_totitle','utf8_toupper','utf8_upper','utf8_xdigit','utf8cache','utf8locale','warnhook','watchaddr','watchok','xmlfp'
,'IArgv','ICmd'
,'IDBcv'
,'IDBgv'
,'IDBline'
,'IDBsignal'
,'IDBsingle'
,'IDBsub'
,'IDBtrace'
,'IDir'
,'IEnv'
,'ILIO'
,'IMem'
,'IMemParse'
,'IMemShared'
,'IOpPtr'
,'IOpSlab'
,'IOpSpace'
,'IProc'
,'ISock'
,'IStdIO'
,'ISv'
,'IXpv'
,'Iamagic_generation'
,'Ian'
,'Iapiversion'
,'Iargvgv'
,'Iargvout_stack'
,'Iargvoutgv'
,'Ibasetime'
,'Ibeginav'
,'Ibeginav_save'
,'Iblockhooks'
,'Ibody_arenas'
,'Ibody_roots'
,'Ibodytarget'
,'Ibreakable_sub_gen'
,'Icheckav'
,'Icheckav_save'
,'Ichopset'
,'Iclocktick'
,'Icollation_ix'
,'Icollation_name'
,'Icollation_standard'
,'Icollxfrm_base'
,'Icollxfrm_mult'
,'Icolors'
,'Icolorset'
,'Icompcv'
,'Icompiling'
,'Icomppad'
,'Icomppad_name'
,'Icomppad_name_fill'
,'Icomppad_name_floor'
,'Icop_seqmax'
,'Icryptseen'
,'Icurcop'
,'Icurcopdb'
,'Icurpad'
,'Icurpm'
,'Icurstack'
,'Icurstackinfo'
,'Icurstash'
,'Icurstname'
,'Icustom_op_descs'
,'Icustom_op_names'
,'Icv_has_eval'
,'Idbargs'
,'Idebstash'
,'Idebug'
,'Idebug_pad'
,'Idef_layerlist'
,'Idefgv'
,'Idefoutgv'
,'Idefstash'
,'Idelaymagic'
,'Idestroyhook'
,'Idiehook'
,'Idirty'
,'Idoextract'
,'Idoswitches'
,'Idowarn'
,'Idumper_fd'
,'Idumpindent'
,'Ie_script',
,'Iefloatbuf'
,'Iefloatsize'
,'Iegid'
,'Iencoding'
,'Iendav'
,'Ienvgv'
,'Ierrgv'
,'Ierrors'
,'Ieuid'
,'Ieval_root'
,'Ieval_start'
,'Ievalseq'
,'Iexit_flags',
'Iexitlist',
'Iexitlistlen',
'Ifdpid',
'Ifilemode',
'Ifirstgv',
,'Iforkprocess',
,'Iformfeed',
'Iformtarget',
'Igeneration',
'Igensym',
'Igid',
'Iglob_index',
'Iglobalstash',
'Ihash_seed'
,'Ihintgv'
,'Ihints'
,'Ihv_fetch_ent_mh'
,'Iin_clean_all'
,'Iin_clean_objs'
,'Iin_eval'
,'Iin_load_module'
,'Iincgv'
,'Iinitav'
,'Iinplace'
,'Iisarev'
,'Iknown_layers'
,'Ilast_in_gv'
,'Ilast_swash_hv'
,'Ilast_swash_key',
,'Ilast_swash_klen'
,'Ilast_swash_slen'
,'Ilast_swash_tmps'
,'Ilastfd'
,'Ilastgotoprobe'
,'Ilastscream'
,'Ilaststatval'
,'Ilaststype'
,'Ilocalizing'
,'Ilocalpatches'
,'Ilockhook'
,'Imadskills'
,'Imain_cv'
,'Imain_root'
,'Imain_start'
,'Imainstack'
,'Imarkstack'
,'Imarkstack_max'
,'Imarkstack_ptr'
,'Imax_intro_pending'
,'Imaxo'
,'Imaxscream'
,'Imaxsysfd'
,'Imemory_debug_header'
,'Imess_sv'
,'Imin_intro_pending'
,'Iminus_E'
,'Iminus_F'
,'Iminus_a'
,'Iminus_c'
,'Iminus_l'
,'Iminus_n'
,'Iminus_p'
,'Imodcount'
,'Imodglobal'
,'Imy_cxt_keys'
,'Imy_cxt_list'
,'Imy_cxt_size'
,'Ina'
,'Inomemok'
,'Inumeric_local'
,'Inumeric_name'
,'Inumeric_radix_sv'
,'Inumeric_standard'
,'Iofsgv'
,'Ioldname'
,'Iop'
,'Iop_mask'
,'Iopfreehook'
,'Iopsave'
,'Iorigalen'
,'Iorigargc'
,'Iorigargv'
,'Iorigenviron'
,'Iorigfilename'
,'Iors_sv'
,'Iosname'
,'Ipad_reset_pending'
,'Ipadix'
,'Ipadix_floor'
,'Iparser'
,'Ipatchlevel'
,'Ipeepp'
,'Iperl_destruct_level'
,'Iperldb'
,'Iperlio'
,'Ipidstatus'
,'Ippid'
,'Ipreambleav'
,'Iprofiledata'
,'Ipsig_name'
,'Ipsig_pend'
,'Ipsig_ptr'
,'Iptr_table'
,'Ireentrant_buffer'
,'Ireentrant_retint'
,'Ireg_state'
,'Iregdummy'
,'Iregex_pad'
,'Iregex_padav'
,'Ireginterp_cnt'
,'Iregistered_mros'
,'Iregmatch_slab'
,'Iregmatch_state'
,'Irehash_seed'
,'Irehash_seed_set'
,'Ireplgv'
,'Irestartjmpenv'
,'Irestartop'
,'Irpeepp'
,'Irs'
,'Irunops'
,'Isavebegin'
,'Isavestack'
,'Isavestack_ix'
,'Isavestack_max'
,'Isawampersand'
,'Iscopestack'
,'Iscopestack_ix',
,'Iscopestack_max'
,'Iscopestack_name'
,'Iscreamfirst'
,'Iscreamnext'
,'Isecondgv'
,'Isharehook'
,'Isig_pending'
,'Isighandlerp'
,'Isignalhook'
,'Isignals'
,'Islab_count'
,'Islabs'
,'Isort_RealCmp'
,'Isortcop'
,'Isortstash'
,'Isplitstr'
,'Isrand_called'
,'Istack_base'
,'Istack_max'
,'Istack_sp'
,'Istart_env'
,'Istashcache'
,'Istatbuf'
,'Istatcache'
,'Istatgv'
,'Istatname'
,'Istatusvalue'
,'Istatusvalue_posix'
,'Istatusvalue_vms'
,'Istderrgv'
,'Istdingv'
,'Istrtab'
,'Isub_generation'
,'Isubline'
,'Isubname'
,'Isv_arenaroot'
,'Isv_count'
,'Isv_no'
,'Isv_objcount'
,'Isv_root'
,'Isv_serial'
,'Isv_undef'
,'Isv_yes'
,'Isys_intern'
,'Itaint_warn'
,'Itainted'
,'Itainting'
,'Ithreadhook'
,'Itimesbuf'
,'Itmps_floor'
,'Itmps_ix'
,'Itmps_max'
,'Itmps_stack'
,'Itop_env'
,'Itoptarget'
,'Iuid'
,'Iunicode'
,'Iunitcheckav'
,'Iunitcheckav_save',
,'Iunlockhook'
,'Iunsafe'
,'Iutf8_X_L'
,'Iutf8_X_LV'
,'Iutf8_X_LVT'
,'Iutf8_X_LV_LVT_V'
,'Iutf8_X_T'
,'Iutf8_X_V'
,'Iutf8_X_begin'
,'Iutf8_X_extend'
,'Iutf8_X_non_hangul'
,'Iutf8_X_prepend'
,'Iutf8_alnum'
,'Iutf8_alpha'
,'Iutf8_ascii'
,'Iutf8_cntrl'
,'Iutf8_digit'
,'Iutf8_graph'
,'Iutf8_idcont'
,'Iutf8_idstart'
,'Iutf8_lower'
,'Iutf8_mark'
,'Iutf8_perl_space'
,'Iutf8_perl_word'
,'Iutf8_posix_digit'
,'Iutf8_print'
,'Iutf8_punct'
,'Iutf8_space'
,'Iutf8_tofold'
,'Iutf8_tolower'
,'Iutf8_totitle'
,'Iutf8_toupper'
,'Iutf8_upper'
,'Iutf8_xdigit'
,'Iutf8cache'
,'Iutf8locale'
,'Iwarnhook'
,'Iwatchaddr'
,'Iwatchok'
,'Ixmlfp'
,'GNo'
,'GYes'
,'Gappctx'
,'Gcharclass'
,'Gcheck'
,'Gcsighandlerp'
,'Gcurinterp'
,'Gdo_undump'
,'Gdollarzero_mutex'
,'Gfold_locale',
,'Gglobal_struct_size'
,'Ghexdigit'
,'Ghints_mutex'
,'Ginterp_size'
,'Ginterp_size_5_10_0'
,'Gkeyword_plugin'
,'Gmalloc_mutex'
,'Gmmap_page_size'
,'Gmy_ctx_mutex'
,'Gmy_cxt_index'
,'Gop_mutex'
,'Gop_seq'
,'Gop_sequence'
,'Gpatleave'
,'Gperlio_debug_fd'
,'Gperlio_fd_refcnt'
,'Gperlio_fd_refcnt_size'
,'Gperlio_mutex'
,'Gppaddr'
,'Grevision'
,'Grunops_dbg'
,'Grunops_std'
,'Gsh_path',
,'Gsig_defaulting'
,'Gsig_handlers_initted'
,'Gsig_ignoring'
,'Gsig_sv'
,'Gsig_trapped'
,'Gsigfpe_saved'
,'Guse_safe_putenv'
,'Gveto_cleanup'
,'ppaddr'
,'Gsubversion'
,'Gsv_placeholder'
,'Gthr_key'
,'Gtimesbase'
,'Gversion'
,'Gwatch_pvx','watch_pvx');

my @file_patterns;

push @file_patterns, qr/.*\.h$/;
push @file_patterns, qr/.*\.c$/;
push @file_patterns, qr/.*\.xs$/;
push @file_patterns, qr/.*\.xsi$/;


local $/;
print scalar(@pl_words);
#imy $PL_word = 'na';
#@pl_words =('na','na');
my $count=0;

foreach my $file_pattern (@file_patterns){

foreach my $PL_word (@pl_words){

my $base = 'C:/DBD.Oracle.svn/branches/polute/';

my @search_queue = ($base);

$count++;
  my $content_pattern = qr/\b$PL_word\b/;

  while (my $current = shift @search_queue) {
  #  print "Checking $current...\n";
    if ( -d $current and $search_recursive) {
        opendir MYDIR, $current;
        my @new_files = grep !m/^\.\.?$/, readdir MYDIR;
        for my $file (@new_files) {
            $file = $current . '\\' . $file;
        }
        closedir MYDIR;
        #print "nf: " . join (",",@new_files) . "\n";
        push @search_queue, @new_files;
    }
    if ($current =~ $file_pattern) {
        if($search_content == 1 and (! -d $current)) {
            #print "scanning $current\n";
            open my $cfh,"<$current";
            my $content = <$cfh>;
            close $cfh;
            if ($content =~ $content_pattern) {
                print "found '".$PL_word."'  in file $current\n";
            }
        }
        else {
            print "2$current\n";
        }
    }
  }
}
}
print "done. $count\n";
