Bundling up a couple of announcements for my contributed Perl modules ... I
think there's some pretty neat stuff here, which is why I went to the
trouble of polishing it up and releasing it. Check it out - but note that
this is for fairly advanced Perl programmers. At the least, anyone who's
currently using my IPC::ClearTool module should check into the below.
1. First, IPC::ClearTool is now ported to Windows. This is actually a
different implementation under a unified interface - it uses the ClearCase
COM API (officially known as the ClearCase Automation Library or CAL) on
Windows and continues to use a cleartool co-process on UNIX. But while the
implementations are different, the behavior is the same on UNIX or Windows
(with a few caveats - see the full docs). The CAL part requires CC 3.2.1 or
above, BTW. There are also some new features and fixes for UNIX.
For those who aren't familiar with it, IPC::ClearTool speeds up large-scale
ClearCase programming jobs by keeping one cleartool process running in the
background and feeding commands to it. This can result in massive speedups
- I usually say between twice and 10 times as fast depending on various
factors. The new Windows version sends cleartool commands to the CAL
CmdExec method instead; speedups appear to be similar to UNIX.
2. IPC::ClearTool always had two major flaws as a programming model: (1) it
didn't run on Windows and (2) the API was complicated and idiosyncratic,
making for a substantial learning curve and requiring a leap of faith to
write to it (faith that IPC::ClearTool would be up to the task, that the
program wouldn't ever need to run on Windows, etc.). The first is now
addressed; what about the second? That's where ClearCase::Argv comes in.
Briefly, it provides its own versions of system(), exec(), and qx() (aka
backquotes) to give any program that runs cleartool these advantages:
=> Lots of automatic interoperability help. For instance, it will
(optionally) convert pathnames containing / to \ on Windows. And, since a
command such as system('cleartool', 'pwv', '-s') is not submitted to a
shell on UNIX but IS on Windows, which usually leads to quoting nightmares,
it will automatically quote it against shell expansion on Windows only. All
of these behaviors are configurable.
=> By throwing a switch you can send cleartool commands to IPC::ClearTool.
This solves problem (2) above by making it trivial to switch between the
traditonal fork/exec model and a co-process/CAL for speed.
=> It provides a layer of standard semantics for debugging, verbosity, etc.
For instance the 'dbglevel' attribute can be set to print out all commands
as executed in all these various ways:
ClearCase::Argv->dbglevel(1); # in the code
export CLEARCASE_ARGV_DBGLEVEL=1; # in the env
-/dbglevel=1 # on the cmd line
And the same for other attrs such as 'noexec', 'autofail', etc. It can be
very handy to have a whole suite of tools which all obey such
conventions. In fact this same technique can be used to turn on/off use of
IPC::ClearTool by passing -/ipc_cleartool=1. The -/ prefix is chosen so as
to not conflict with any "real" flags and in any case this feature is optional.
Thie code is on CPAN in my author area (DSB) and should be easily findable
via http://theory.uwinnipeg.ca/search/cpan-search.html. You want (at least):
ClearCase::Argv 0.17
Argv 0.46
IPC::ChildSafe 3.08
Later versions should be presumed compatible improvements unless stated
otherwise. Everything is (I hope) documented pretty exhaustively in the
PODs. But since it presents a dizzying variety of supported interfaces I'll
give a brief summary here:
You can override the builtin definitions of system, exec, and qx and use
the functional interface. This is simplest for converting an existing script:
use ClearCase::Argv qw(system exec qv);
my $view = qv('cleartool', 'pwv', '-s');
chomp $view;
where before you might have just said:
my $view = `cleartool pwv -s`;
chomp $view;
One caveat - since Perl doesn't allow qx() to be overridden we need to use
the alias qv() instead. Next, if you really don't want to mess with your
namespace you can do the same thing without overriding:
use ClearCase::Argv;
my $view = Argv::qv('cleartool', 'pwv', '-s');
Note that we didn't bother with the ClearCase:: prefix. In this case the
subclassed ClearCase::Argv::system() would just be calling through to
Argv::system() anyway so we can save some typing. But probably a better way
to save typing is:
use ClearCase::Argv qw(ccsystem ccexec ccqv);
my $view = ccqv(qw(pwv -s));
Since the cc*() versions handle prepending of 'cleartool' automatically.
But all of the above are hacks; the "real" ClearCase::Argv is an OO interface:
use ClearCase::Argv;
my $view = ClearCase::Argv->new(qw(pwv -s))->qx;
There's lots more but that's all I'll mention here. If I didn't say so
before, BTW, the real action is in the Argv module; ClearCase::Argv is just
a CC front-end to it.
I really hope people will find this stuff useful. I'm currently using it to
write a suite of tools that need to run seamlessly on UNIX and Windows with
great success. The speedups inherent in turning on the -/ipc_cleartool
switch are just gravy.
-David Boyce
PS In addition to the documentation, the test script for ClearCase::Argv is
designed to double as a demo. Read its output carefully and you'll know a
lot about what's going on. Of course you can steal code from it too. Also,
there are a few sample programs in the ./examples subdir.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This archive was generated by hypermail 2b29 : Sun May 06 2001 - 00:22:30 EDT