Thanks for the help. The while loop move makes sense! I knew this looked silly, 
but with the rest of the code, I am looping in many arrays. In this section I 
am only working with the first indice (the .vmx one).

Is it actually incorrect to run: stop_it(@DNS); aside from maybe looking 
strange?

So the `/usr/bin/vmware-cmd \"$_[0]\" gettoolslastactive -q`; is correct where 
the var gets inserted?

Thanks!
jlc

-----Original Message-----
From: Chas Owens [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 04, 2007 8:15 PM
To: Joseph L. Casale
Cc: beginners@perl.org
Subject: Re: syntax error of some sort?

On 7/4/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote:
snip
>                 if ($state == 'on') {
>                                 'vmware-cmd $_[0] stop soft';
>                                 my $tools = `/usr/bin/vmware-cmd \"$_[0]\" 
> gettoolslastactive -q`;
>                                 chomp($tools);
>                 }
>                 while (($state == 'on') && ($tools == 1)) {
>                                 sleep 30;
>                                 my $tools = `/usr/bin/vmware-cmd \"$_[0]\" 
> gettoolslastactive -q`;
>                                 chomp($tools);
>                 }
> }
snip
> I am getting two errors I think, and I don't understand them.
> The first is the second use of my $tools, how can I do this
> without causing an error? Can I just start using $tools right after without 
> my?

The while belongs inside of the if like this:

               if ($state == 'on') {
                               'vmware-cmd $_[0] stop soft';
                               my $tools = `/usr/bin/vmware-cmd
\"$_[0]\" gettoolslastactive -q`;
                               chomp($tools);

                               while ($tools == 1) {
                                              sleep 30;
                                              $tools =
`/usr/bin/vmware-cmd \"$_[0]\" gettoolslastactive -q`;
                                              chomp($tools);
                              }
               }

snip
> The second I am sure is the darn () in the file names I am feeding
> into the function. Can someone shed some light :) I need to call the
> first indices of many arrays that get passed into this function, so I
> was thinking $_[0] was what I need. Problem is that the execution
> of vmware-cmd needs the value of $_[0] passed to it inside quotes.
snip

In your example $_[0] is
"/vmfs/volumes/467f06a5-7d59c067-35cb-0007e9153886/Web & DNS (Win2003
Std x32)/Web & DNS (Win2003 Std x32).vmx"

If you want to perform stop_it on or with many values you will need to
put a loop outside or inside the sub.  Given the way your code is
currently written this should work:

stop_it($_) for @DNS;





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to