The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/bin/perl
use ClearCase::Argv 1.11 qw(ctsystem);

die "Usage: perl $0 <attr-type> <attr-val> <element>\n" unless @ARGV == 3;

ClearCase::Argv->attropts;
ClearCase::Argv->dbglevel(1);

my($attype, $attr, $ccobj) = @ARGV;
my $atval = qq("$attr");

# Making the attribute type, suppressing stderr in case it exists.
ClearCase::Argv->mkattype(qw(-nc), $attype)->stderr(0)->system;

# Demo: making string-valued attrs in traditional fork/exec style.
print "OO/Exec\n";
ClearCase::Argv->mkattr(qw(-replace -nc), $attype, $atval, $ccobj)->system;
print "Func/Exec\n";
ctsystem(qw(mkattr -replace -nc), $attype, $atval, $ccobj);

# Demo: making string-valued attrs in IPC::ClearTool style.
if (ClearCase::Argv->ipc(2)) {
    print "OO/IPC\n";
    ClearCase::Argv->mkattr(qw(-replace -nc), $attype, $atval, $ccobj)->system;
    print "Func/IPC\n";
    ctsystem(qw(mkattr -replace -nc), $attype, $atval, $ccobj);
    ClearCase::Argv->ipc(0);
}

# Demo: making string-valued attrs in ClearCase::CtCmd style.
if (ClearCase::Argv->ctcmd(2)) {
    print "OO/CtCmd\n";
    ClearCase::Argv->mkattr(qw(-replace -nc), $attype, $atval, $ccobj)->system;
    print "Func/CtCmd\n";
    ctsystem(qw(mkattr -replace -nc), $attype, $atval, $ccobj);
    ClearCase::Argv->ctcmd(0);
}