[kw-pm] playing with udev: the followup

Robert P. J. Day rpjday at crashcourse.ca
Mon May 31 09:37:19 PDT 2010


  since folks here were nice enough to help me out, here's the end
result of my writeup which i might use as the basis of another column
at linux.com:

http://www.crashcourse.ca/wiki/index.php/Building_and_testing_udev

  my only issue that i'm tempted to submit a patch for involves this
code in the test/udev-test.pl script:

                if ($rules->{exp_add_error}) {
                        print " as expected\n";
                } else {
                        print "\n";
                        system("tree $udev_root");
                        print "\n";
                        $error++;
                        sleep(1);
                }

  all well and good, except if the user doesn't have the "tree"
package installed and something goes wrong, there's no system "tree"
command and that invocation of system() fails rather inelegantly.

  what would be the un-perl-like one correct way to handle cases like
that?  as in, don't run a command unless you know it's there, perhaps
replace it with an invocation of "ls -lR" or something.  is there a
canonical perl way to do checks like that?  thanks.

rday

-- 

========================================================================
Robert P. J. Day                               Waterloo, Ontario, CANADA

            Linux Consulting, Training and Kernel Pedantry.

Web page:                                          http://crashcourse.ca
Twitter:                                       http://twitter.com/rpjday
========================================================================


More information about the kw-pm mailing list