in reply to code critique
Here are a few suggestions:-
I think you should do your options handling before you assign to variables from @ARGV because your options will be in @ARGV until the call to getopts() strips them out.
I think your chomp($when); is superfluous because there is no line terminator in $when as you've just created it with a "%m%d%y" template to strftime().
Your "help" text could be output by a single print statement with either a comma-separated list of lines or a HEREDOC.
Square brackets don't need to be escaped in a double-quoted string. They do in a regular expression if you want to match a literal one as they are regex metacharacters.
I've not used Expect but if the -re flag implies that the next argument should be a regex pattern, be aware that a ? is a metacharacter meaning zero or one of the preceding term.
You may be able to make your expect/send code more readable by setting up a dispatch table, although some prompts can generate two different responses so the technique can't be applied universally:
my %dispatchTable = ( ... 'Queue Priority' => "\r", ... ); ... expectSend( 'Queue Priority' ); ... sub expectSend { my $prompt = shift; $exp->expect( 10, '-re', $prompt ); $exp->send( $dispatchTable{ $prompt }; }
I hope these points are helpful.
Cheers,
JohnGG
|
|---|