in reply to help with perl variables

It doesn't appear that the code you posted exhibits the behavior your are describing. But it's an incomplete snippet. I encourage you to post well formatted code that is complete enough that we can run it, that exhibits the behavior you are describing, that passes strict and warnings, and that is under 30 lines in length. If that means you post an example that stands as a proxy for larger code, so be it. In boiling your lengthy code down to a small test case, you may spot the problem yourself. But even if you don't, you'll at least provide us with something that we can run to see what you're talking about.

And please, don't name variables $FOO1, $FOO2, $FOO3, $FOO4, etc. That's what actual arrays are for.


Dave

Replies are listed 'Best First'.
Re^2: help with perl variables
by AnomalousMonk (Archbishop) on Sep 03, 2015 at 05:40 UTC
    my $CONNECTCOMMAND1 = "$SSHCOMMAND -ssh $USERNAME1\@$HOST1 -pw $PASSWORD1";
    push (@CONNECTCOMMANDS, "$CONNECTCOMMAND1");

    Furthermore, the idiomatic tic of stringizing something that is already a string, e.g., "$CONNECTCOMMAND1", while it does no harm, also serves no purpose except to be reliably irritating.


    Give a man a fish:  <%-{-{-{-<

      Indeed.

      Just a few days ago I found myself working with code that did just that, and I had to spend a little time tracing through possible reasons why the original coder would have done that.

      If you're going to stringify a scalar that holds a numeric value by wrapping it in quotes, please document that's the reason so that others don't have to wonder if it was intentional. And if that's not the reason, just don't do it. It wastes people's time, wastes a few cycles, clutters the code, clutters its meaning, and drives pedants like me crazy.

      In the case of the code I was looking at, it served no purpose. In the case of this OP, it serves no purpose either.


      Dave