Just to clarify, I can replace use strict 'vars'; with use strict; ?
For this script, you can. I find that coding under the full strictitures keeps me from doing things that I probably didn't mean, and is not that much harder than doing so without.
Could you explain item 2 a bit further, or point me to something that might help me fix it?
Sure. You're calling subs right now like mysub($foo, $bar) where the definition of mysub is something like
sub mysub { $foo ++; some_other_sub($bar); }
It should read like this:
sub mysub { my ($foo, $bar) = @_; #do stuff with $foo and $bar }
This allows you to follow another maxim that should be adhered to in general: declare your variables in the tightest scope that you can. That is to say that if you're using a while loop and some values only hold true for only that iteration of the while loop, you should declare them within the scope of that loop. For a concrete example from your code:
my ($folder, $server_name, $session_name, $protocol, $hexport, $version, $compr, $user); while (<SERVER_LIST>) { next if /$ignore/ ; chop; ( $folder, $server_name, $session_name, $protocol)= split (":"); ($hexport,$version,$compr)=create_port($protocol); $user=create_user($folder); &create_session($server_name, $session_name, $protocol, $user); &create_link($folder, $server_name, $session_name); }
becomes (with some other differences sprinkled in)
while (<SERVER_LIST>) { next if /$ignore/ ; # chomp is safer than chop...read the perldoc for # both of those functions (perldoc -f chop for chop chomp; my ($folder, $server_name, $session_name, $protocol)= split (":"); my ($hexport,$version,$compr)=create_port($protocol); my $user=create_user($folder); # the &sub syntax is not advised in most situations for reasons # that are slightly advanced, sub() suffices create_session($server_name, $session_name, $protocol, $user); create_link($folder, $server_name, $session_name); }
I didn't look too carefully at the code that is called by this block, but I'm pretty sure that the subs create_session and create_link would have to be altered in such a way as to not use global variables to store their information.

I hope this helps. If you have more questions, feel free to ask. I'm more than happy to help!

thor

Feel the white light, the light within
Be your own disciple, fan the sparks of will
For all of us waiting, your kingdom will come


In reply to Re^3: Putty Session Generator by thor
in thread Putty Session Generator by d_jabsd

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.