Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

# I am trying to write a simple script that interrogates
# ClearCase for Checked-out files. When I run the program
# in debug, all seems to go well until I get to a certain
# point. That point is at the end of what I've written to
# date (and I've commented below what problem I'm
# having). I would be most appreciative of any help
# anybody could give.
#! perl -w use strict; use warnings; use Win32::OLE; use Win32::OLE::Variant; # for variant arrays my $ccSelection_Path = 0; # $ccSelection_ values from the WEB my $ccSelection_SubTreeRoot = 1; my $ccSelection_Directory = 2; my $ccSelection_AllInVOB = 3; my $ccSelection_AllVOBs = 4; # Connect to the top-level ClearCase object my $cc = Win32::OLE->new('ClearCase.Application') or die "Could not create Application object\n"; my $COQuery; $COQuery = $cc->CreateCheckedOutFileQuery; $COQuery->{PathArray} = ["cc_views/heller_int_view/Pre_Funding/CustomE +!"]; $COQuery->{User} = "heller"; $COQuery->{PathSelects} = $ccSelection_AllInVOB; my @CheckedOutFiles; @CheckedOutFiles = $COQuery->Apply(); #<--- the problem. my $count; $count = @CheckedOutFiles->Count();
# Everything seems to be working as desired until I
# realized that @CheckedOutFiles is null after the line
# marked above. Why? I don't have a clue.

2006-11-03 Retitled by planetscape, as per Monastery guidelines

( keep:1 edit:27 reap:0 )

Original title: 'Winderz - Using COM and OOP'

Replies are listed 'Best First'.
Re: Having trouble running query in ClearCase OLE interface
by wjw (Priest) on Nov 02, 2006 at 03:39 UTC
    am not familiar with ClearCase, but have you check to make sure that the return is supposed to be a list? Just a thought..

    ...the majority is always wrong, and always the last to know about it...

Re: Having trouble running query in ClearCase OLE interface
by fenLisesi (Priest) on Nov 02, 2006 at 07:27 UTC
    I don't understand this bit: $count = @CheckedOutFiles->Count();. If you are sure that Apply() returns a list of the checked out files in list context, then how about just $count = @CheckedOutFiles;? It is also possible that it returns an object, perhaps an iterator, in which case you may need
    my ($CheckedOutFiles, $count); $CheckedOutFiles = $COQuery->Apply(); $count = $CheckedOutFiles->Count();
    (None of this has been tested). HTH.
      I am trying to translate from a VBS program.
      Following is the applicable portion of that script.
      Dim objCC Set objCC = Wscript.CreateObject("ClearCase.Application") Dim COQuery Set COQuery = objCC.CreateCheckedOutFileQuery Dim CheckedOutFiles Set CheckedOutFiles = COQuery.Apply Dim strMsg strMsg = CheckedOutFiles.Count & " files are checked out: "
      This works well in VBS.
      The COQuery.Apply works like an SQL command in that it populates
      a table with a list of checked-out files. The count command returns
      a list of those checked-out files.
      The really unfortunate thing is that all of ClearCase's examples
      are in VBS. I would MUCH rather be using Perl.

        I would bet that COQuery->Apply returns an array, which you then assign to a standard perl array, @CheckedOutFiles.

        Perl arrays don't have a method called "Count".

        You probably want:

        print scalar @CheckedOutFiles . " files are checked out: "


        --chargrill
        s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)
        Did you try the $CheckedOutFiles idea above?