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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|