Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^5: RFC: beginner level script improvement

by jwkrahn (Monsignor)
on Sep 28, 2013 at 20:32 UTC ( #1056162=note: print w/ replies, xml ) Need Help??


in reply to Re^4: RFC: beginner level script improvement
in thread RFC: beginner level script improvement

### SUB validate_command_line_args ### DOES: perform various sanity + checks on command line argume +nts ############# sub validate_command_line_args { my ($name,$prompt,$configf,$quiet,$outf,$debug,$batchsize,$proto,$ +tacacs,$verbose,$header,$maild +st,$path) = @{ $_[0] }; ... if ( $batchsize > 30 ){ warn("$0:WARNING: More than 25 simultanous connections are NOT + allowed!\nReducing Max_Connec +tions to 25.\n"); $batchsize=25; }elsif ( $batchsize < 0 ){ warn("$0:WARNING: Negative Max_Connections are not permitted, +forking has been disabled.\n") +; $batchsize = 0; } }

The $batchsize variable is lexically scoped to this subroutine so changing its value will have no effect on anything outside this subroutine.


Comment on Re^5: RFC: beginner level script improvement
Select or Download Code
Re^6: RFC: beginner level script improvement
by georgecarlin (Acolyte) on Sep 30, 2013 at 15:55 UTC
    ah yes, thank you for noticing. It's fixed via return to and set in main now.

    I've transformed all of the code but the expect parts by now but want to complete and throughly test it before posting the version 2. However I'm not entirely sure if what I have in mind is going to work.

    The expect-interaction is entirely independent on the protocol so I will consolidate both prior subs, but since most expect calls are similar I would like to create abstract subs and pass params to them as well as an exp-handle ref. is this possible?

    rough example:
    sub expect_main { my $exp = new Expect; $exp->configure_stuff; my $FB = expect_do_something(\$exp, \@expectthese, \@sendthese); } sub expect_do_something { my ($exp,$expectthese,$sendthese) = @_; $exp->expect(5, [ qr/$expectthese->[0]/, sub { $exp->send("$sendthese->[0]");}], [ qr/$expectthese->[1]/, sub { $exp->send("$sendthese->[1]");}], ); my $fb = $exp->before(); return $fb; }
    Would this work or is it impossible to interact with the expect handle and methods this way? Or is there maybe a better way? Thanks in advance.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1056162]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2014-12-28 00:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls