To better understand the dependencies in SMF I had written a shell script to print the dependency tree of a given service.  Recently I started learning perl and decided to rewrite the script in perl and at the same time enhance it a bit.

The script is available at following two locations:
http://blogs.sun.com/roller/resources/jkini/svcstree
http://mediacast.sun.com/details.jsp?id=3849

Run the script without any arguments and it'll dump a help text.  Rest should be quite easy after that.  Let me know if it isn't.  This is my first perl script.  I'm sure there is plenty of scope of improvement...

Comments:

Quick review:
  • qw(foo (bar) bletch) does the right thing; no need for \ there.
  • Since it's all one package, not sure why you used "our" instead of "my" there.
  • I'd have "sub usage" take an arg, instead of all those separate prints before calling usage.
  • "sub showdep" is too long, and relies on globals to do different things. Break it down to a section that decides what to do, then calls various routines to do the parts. Keep subroutines down to 10-15 lines of code.
  • And, I'd use real POD, instead of a fake fixed-text thing that looks like pod2text. Then I could have had that manpage as HTML or texinfo, or any of a dozen other formats.

Posted by Randal L. Schwartz on November 22, 2005 at 09:51 PM IST #

Thanx Randal for the comments. I'll to modify the script. Of course, I'll have to first improve my knowledge of Perl.

Posted by Jayakara Kini on November 22, 2005 at 10:04 PM IST #

Nice little script except, on OpenSolaris (build 28) it seems to loop over and over, not tried it on Solaris 10 yet. Cheers, Lasse

Posted by Lasse Osterild on January 03, 2006 at 04:48 PM IST #

Post a Comment:
Comments are closed for this entry.

This blog copyright 2009 by jkini