[p4perl] P4Perl in 2007.3

Scott Lavender Scott.Lavender at visiprise.com
Fri Jun 20 11:54:06 PDT 2008

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";
        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.


2008/6/20 Scott Lavender <Scott.Lavender at visiprise.com>:
> I know there were changes when P4Perl was rolled into 2007.3. How did
> return for Fetch change. I have a subroutine that expects it to be a
> reference. Somehow it has changed to an array, or string. I'm not
> sub getGroup {
>     my ( $groupName ) = @_;
>     return = $p4->FetchGroup( $groupName );
> }
> Can someone explain how I should alter my scripts to account for this?
> 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
> International Traffic in Arms Regulations (ITAR). Please direct
inquiries to
> ITAR at visiprise.com for instructions and authorization to transmit such
> _______________________________________________
> p4perl mailing list
> p4perl at perforce.com
> http://maillist.perforce.com/mailman/listinfo/p4perl

More information about the p4perl mailing list