On Wednesday 26 May 2010 15:49:37 Andros Zuna wrote: > Hi! > I am trying to write a perl code that will retry the same command over > and over again until the return value is 0. > This is what I got for now: > > #! /usr/bin/perl > use warnings; > use strict; > > $command = 'ls -l'; > > if (system($command) == 0) { > } > elsif(system($command != 0)) {
That should be <<elsif (system($command) != 0)>> - you've misplaced the parentheses. > print "Failed to execute: $command\n"; > my $c++ > } > > I'm not shure to test it, because I don't know any unix commands that > gives other than 0 in return > (I'm a n00b, but willing and trying to learn), could anyone please > take a look and see if this is correct, and if not, help me?? There's always "false" and "test": * http://en.wikipedia.org/wiki/True_and_false_%28Unix%29 * http://en.wikipedia.org/wiki/Test_%28Unix%29 Regards, Shlomi Fish > > Tnx :) -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ What does "Zionism" mean? - http://shlom.in/def-zionism God considered inflicting XSLT as the tenth plague of Egypt, but then decided against it because he thought it would be too evil. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/