## Set up default environment ## allowed options for define{} blocks # source # destination # unkdest # rule_once define { source = "/u20/home/gvc/gvc_dtfr" # Location of source ports. destination = "/u90/gvc_archive/new" # Destination for all ports. unkdest = "/u90/gvc_archive/tmp" # Where should files go if # a destination cannot be # determined or created for # a port. default_mask= "mmddyyyy" # Default date mask for the # dest directories. # If this rule is not NULL then only the rules # specified in this variable will be run and # the rest of the rules will be ignored. # See the conf.doc for more on this. # This next should be a rule or a # list of rules delimited commas. rule_once = "5" } #####*******##### ## default macros #####*******##### ## allowed options for rules! # source # destination # unkdest # test_only # regex # port # macro # Arbor AMA files. # matches F*-P*.####.ama # datefield is the number between P*. and .ama macro arbor_ama { regex = "F.*?-P.*?\.(\d+)\.ama:::$1:::mmdd" } rule 5 { port = "150,152" macro = "arbor_ama,usl1,usl2,uslnull,rpt,arbor1_1"; } #### # Walk the hash of complex data structures called $macros # and $rules. # starting the traversal of %$rules while ( my ($rule_key,$rule_val) = each(%$rules) ) { # Now, breaking out the hash references from $rule_val while ( my ($nkey,$nval) = each(%$rule_val) ) { # Simple enough, if the key is "macro" then we have found # our macros in the complex data structure. if ( $nkey eq "macro" ) { # Now, we need to start to traverse the %$macros structure # and we will do the merge. while ( my ($macro_key,$macro_val) = each(%$macros) ) { # Now, walk the array reference that was contained in the # reference $nval (which is a reference to an array) for ( @$nval ) { # Now, if the key from the macro hash matches the # rule that is referencing a macro then... if ( $macro_key eq $_ ) { # Replace the macro name with the actual regex from the # macro. map { push(@{$$rules{$rule_key}{regex}},$_); } @{$$macros{$_}{regex}}; # Now that we have the macros mapped to the rules # we can drop the macros from the rules hashes # since they are dead weight now anyway.. delete(%{$rule_val}->{macro}); } } } } } }