in reply to Help for a beginner

It would probably help if you deleted line 12, which sets $strComputer to "." even after you potentially assigned $ARGV[0] to it.

Replies are listed 'Best First'.
Re^2: Help for a beginner
by Anonymous Monk on Mar 02, 2007 at 19:24 UTC
    Or he could instead just copy the if-else block above that assignment and paste it below the assignment.

    It would be like that old saying, "If you love someone, set them free -- if they come back, assign a typeglob to them."

    :D

Re^2: Help for a beginner
by bobbruce0584 (Initiate) on Mar 02, 2007 at 19:27 UTC
    Thank you so much. That worked. What was the $strComputer doing? I thought that you had to have that in there so that if nothing was called out it would default to the local host.
      You're simply overwriting it with the assignment operator on line 12. A common way to deal with ensuring a default value is set is through the use of a C -style OR:
      $strComputer = $ARGV[0] || '.';

        Of course be careful using this idiom if "0" is a valid value (in that case an assign-the-default-first-and-overwrite implementation is better).

        Although it derives from C (many of Perl's operators do), I doubt it is useful to call || a "C style or". It's much more helpful to call it a "locical or" to distinguish it from | which is a "bitwise or" (also found in C). The third variant 'or' is called "binary or" by the way.


        DWIM is Perl's answer to Gödel