[p4perl] P4Perl in 2007.3

G Barthelemy gb.perforce at googlemail.com
Fri Jun 20 14:08:48 PDT 2008


Hi,

1) I just realised what one of the problem is: now tagged output is on
by default. In that mode P4::RunGroups() will output all the groups
and their content too (just try "p4 -Ztag groups" to see what I mean).
Not sure whether that should be considered a p4 bug or not. Your
script is looking for a list of groups first, and then loops through
that to get the content of each group.

2) Another problem is that you are using FetchGroups, as pointed out
by Tony. So combining 1 and 2, I would rewrite getGroups as follows:

sub getGroups {
        $p4->Tagged(0);
        my @ret = $p4->RunGroups();
        $p4->Tagged(1);
        return @ret;
}

or simply return $p4->RunGroups() and surround the call to the sub
with the Tagged(0) / (1).

As an aside, you may want to check for group Owners as well. Those are
users too.

Guillaume


On Fri, Jun 20, 2008 at 7:54 PM, Scott Lavender
<Scott.Lavender at visiprise.com> wrote:
> Sorry, that was a typo. The actual subroutine did not have the '='. Here
> is the test code that I have written. It returns "None" for all groups.
> If I add a simple print of $groupHash, it prints the entire groups
> record. This tells me that the Fetch is not returning a Hash.
>
> # Get a list of all Perforce groups
> @groups = getGroups();
> print "\nThere are " . ($#groups + 1) . " groups defined.\n\n";
>
> #See if there are any members...
> foreach $groupName ( @groups )
> {
>    $groupHash = getGroup( $group );
>    if( defined $groupHash->{ 'Users' } )
>    {
>        print "Found users\n";
>    }
>    else
>    {
>        print "None\n";
>    }
> }
>
> sub getGroups {
>    return $p4->FetchGroups();
> }
>
> sub getGroup {
>    my ( $groupName ) = @_;
>
>    return $p4->FetchGroup( $groupName );
> }
>
> -----Original Message-----
> From: G Barthelemy [mailto:gb.perforce at googlemail.com]
> Sent: Friday, June 20, 2008 2:29 PM
> To: Scott Lavender
> Cc: p4perl at perforce.com
> Subject: Re: [p4perl] P4Perl in 2007.3
>
> FetchGroup ($groupName) should return a hashref in 2007.3.
>
> P4::FetchGroup($groupName) is not the same as P4::RunGroup("-o",
> $groupName), although both are a shorthand for P4::Run(group, "-o",
> $groupName) which now returns either an array or a reference to an
> array in scalar context (array of hashes to be more precise). However
> P4::FetchGroup only returns the first element of this array of hashes,
> in the form of a hashref, so it's adequate for commands that return
> just one item such as p4 group -o, p4 user -o, p4 change -o.
>
> Remove the equal sign to the right of your return statement, though.
>
> Anyway, if in doubt you can always use ref() (see
> http://perldoc.perl.org/functions/ref.html) to determine the type of
> reference returned by a method.
>
> Guillaume
>
> 2008/6/20 Scott Lavender <Scott.Lavender at visiprise.com>:
>> I know there were changes when P4Perl was rolled into 2007.3. How did
> the
>> return for Fetch change. I have a subroutine that expects it to be a
> has
>> reference. Somehow it has changed to an array, or string. I'm not
> sure.
>>
>> sub getGroup {
>>     my ( $groupName ) = @_;
>>
>>     return = $p4->FetchGroup( $groupName );
>> }
>>
>> Can someone explain how I should alter my scripts to account for this?
> I
>> tried using ParseSpec to convert to a hash, but started getting
> errors. Any
>> help would be appreciated.
>>
>> Thanks.....
>> Scott Lavender | SCM Specialist | Visiprise | office: 770.619.4166 |
>> www.visiprise.com
>>
>>
>> It is our company policy not to accept email of any data controlled by
> the
>> International Traffic in Arms Regulations (ITAR). Please direct
> inquiries to
>> ITAR at visiprise.com for instructions and authorization to transmit such
> data.
>>
>>
>> _______________________________________________
>> p4perl mailing list
>> p4perl at perforce.com
>> http://maillist.perforce.com/mailman/listinfo/p4perl
>>
>>
>



More information about the p4perl mailing list