[p4perl] Using global options with P4Perl.
Tony Smith
tony at smee.org
Wed Feb 15 09:30:50 PST 2006
Hi Dan,
David Weintraub has covered some of the background - thanks David!
There are a few points which I'd like to clarify:
In P4Perl, there a three places you get the results of commands:
1. The return value of the command contains all the 'successful' output:
things that 'p4 -s' would tag with 'text' or 'info'.
2. The Warnings() array contains all warnings received during command
execution: 'p4 -s' would tag those with 'error'
3. The Errors() array contains all errors received during execution of the
command: 'p4 -s' would also tag those with 'error'.
These rules apply to all commands whether you're using Tagged()/ParseForms()
mode or not.
ParseForms() mode includes Tagged() mode, but also converts Perforce forms
into hashes - and vice-versa. Very handy. I rarely code without it.
So, in your case, if you wanted to get to the description of a changelist you
might use something like this:
#!/usr/bin/perl
use P4;
my $p4 = new P4;
$p4->ParseForms();
$p4->Connect() or die( "Can't connect to Perforce" );
my $cl = $p4->Describe( "-s", $changelist );
# Check $p4->Errors() and/or $p4->Warnings() for problems
my $desc = $cl->{ 'desc' };
print( $desc, "\n" );
The fact that Describe() has returned a hash makes getting to the description
trivial.
Hope that helps!
Tony
On Wednesday 15 February 2006 16:36, daniel.jacobs at symbian.com wrote:
> Hi Tony,
>
> Thanks for the prompt response.
>
> I wanted to parse the output, and I had used the global -s option in P4
> before, as the P4 docs state it's meant to aid parsing. It wasn't for
> anything special just trying to match the lines of output that match paths
> in certain areas of our P4 depot.
>
> Thanks again.
>
> Dan
>
>
>
>
> Tony Smith <tony at smee.org>
> 15/02/2006 16:29
>
> To
> p4perl at perforce.com
> cc
> daniel.jacobs at symbian.com
> Subject
> Re: [p4perl] Using global options with P4Perl.
>
>
>
>
>
>
> Hi Daniel,
>
> > I'm using the P4Perl interface and I'm having trouble working out how to
> > use global options. For example, I'd like to run the command
> >
> > p4 -s describe -s 69505
> >
> > which prepends each line with text like this:
> >
> > text:
> > info1:
> > text:
> > exit:
> >
> > I've tried things like
> >
> > $p4->Run("-s", "describe", "-s", "69505");
> >
> > and
> >
> > $p4->Run("-s describe", "-s", "69505");
> >
> > but to no avail. Any suggestions?
>
> You can't do it, and the main (non-technical) reason for that is that you
> shouldn't need to: there are much better ways to do things in P4Perl.
>
> If you can tell me what you're trying to achieve I'd be happy to offer
> some
> advice.
>
> Tony
>
>
>
>
> -----------------------------------------
> Don't miss out on your chance to...Do more with Symbian. Make sure you
> visit the Symbian Stand, B20, at 3GSM 2006, 13-16 February, Barcelona,
> Spain.
> **********************************************************************
> Symbian Software Ltd is a company registered in England and Wales with
> registered number 4190020 and registered office at 2-6 Boundary Row,
> Southwark, London, SE1 8HP, UK. This message is intended only for use by
> the named addressee and may contain privileged and/or confidential
> information. If you are not the named addressee you should not disseminate,
> copy or take any action in reliance on it. If you have received this
> message in error please notify postmaster at symbian.com and delete the
> message and any attachments accompanying it immediately. Neither Symbian
> nor any of its Affiliates accepts liability for any corruption,
> interception, amendment, tampering or viruses occurring to this message in
> transit or for any message sent by its employees which is not in compliance
> with Symbian corporate policy.
> **********************************************************************
>
>
> !DSPAM:43f35947174676410836674!
More information about the p4perl
mailing list