in reply to Re^2: Main logic of this script (summary/abstract/outline)
in thread Main logic of this script

from 208 to 28 and 18

options var init stuff

# if($opt_h) # if($opt_O) # if($opt_O =~ /^connection$|^conn$|^c$/i) # elsif ($opt_O =~ /^operation$|^op$|^o$/i) # elsif ($opt_O =~ /^sort$|^so$/i) # elsif ($opt_O =~ /^statistics$|^statistic$|^stats$|^ +stat$|^st$/i) # elsif ($opt_O =~ /^e|^echo$/i) # else # else # if($opt_S =~ /^(\d+)\/([A-Za-z]+)\/(\d+)\:(\d+):(\d+):(\d+)$/) # elsif ($opt_S =~ /^(\d+):(\d+):(\d+)$/) # else # if($opt_S) # if($opt_E =~ /^(\d+)\/([A-Za-z]+)\/(\d+)\:(\d+):(\d+):(\d+)$/) # elsif ($opt_E =~ /^(\d+):(\d+):(\d+)$/) # else # if($opt_E) # if($opt_S) # if($lower_yr) # if($opt_E) # if($upper_yr) # if($output_format =~ /^connection$|^operation$/) # unless($ARGV[0]) # if($ARGV[1]) # else # elsif ($output_format =~ /^sort$|^echo$|^stat$/) # if($ARGV[0]) # else

meat and potatoes (read the log)

# if($output_format eq 'operation') # while(<ACCESS_LOG>) # if($opt_v) # foreach(keys(%pending)) # if($output_format eq 'connection') # while(<ACCESS_LOG>) # if($opt_v) # foreach(keys(%pending)) # if($output_format eq 'sort') # while(<ACCESS_LOG>) # foreach(@conn_nums) # if($output_format eq 'stat') # while(<ACCESS_LOG>) # if($result_count > 0) # else # if($output_format eq 'echo') # while(<ACCESS_LOG>) # if($in_file)

Replies are listed 'Best First'.
Re^4: Main logic of this script (summary/abstract/outline)
by Anonymous Monk on Mar 09, 2015 at 09:39 UTC

    So the skimmable version might have been (or the new refactored version might be)

    #!/usr/bin/perl -- Main( @ARGV ); exit( 0 ); sub Main { use Getopt::Long; my %opt; GetOptions( \%opt, ... ); my %needed = ValidateOptionsAndInitializeStuffWeNeed( \%opt ); return PrintHelp() if $opt{help_needs_to_happen}; return ReadTheLogBasedOnFormat( \%opt , \%needed ); } sub ValidateOptionsAndInitializeStuffWeNeed { my( $optref ) = @); ... if( ... ){ die "Unknown output type ..."; } ... }