On May 26, 2010, at 9:43 AM, Andros Zuna wrote: > Ok, I see, so the code should look somehow like this: > > #! > /usr/bin/perl > > use > warnings; > use > strict; > > > $command = "ls > -l";
^^ Strongly suggest you use full paths here. > > while (system($command) != 0) > { > my > $c++ > } You should declare $c outside of the loop, and increment it inside of the loop. Like so: my $c = 0; while (system($command) != 0) { $c++; } print "The count is: $c\n"; > > But how could I test if the command executes if the return value changes? > Well that changes things a bit. If you want to actually execute different blocks of code for different return values, then you need to combine the while loop with an if/else, like so: my $loop = 1; my $c = 0; while ($loop) { if (system($command) == 0) { $loop = 0; ## End the loop ## Code here for zero return } else { ## Code here for non-zero return } $c++; } -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/