List Info

Thread: Using global options with P4Perl.




Using global options with P4Perl.
user name
2006-02-23 16:59:03
Scratch that... I see you call P4tag before you connect. 

-Mark

-----Original Message-----
From: Rainey, Mark (Cleveland) 
Sent: Thursday, February 23, 2006 11:48 AM
To: p4perlperforce.com
Subject: RE: [p4perl] Using global options with P4Perl.

I would like to user the P4::Tagged method but the
documentation off of the
perforce website doesn't have it.  All I see is
$p4->SetProtocol(tag,'');
Is that the same thing?
 
Thanks,
Mark 

________________________________

From: p4perl-bouncesperforce.com [mailto:p4perl-bouncesperforce.com] On
Behalf Of Weintraub, David
Sent: Wednesday, February 15, 2006 12:13 PM
To: daniel.jacobssymbian.com; p4perlperforce.com
Subject: Re: [p4perl] Using global options with P4Perl.


P4Perl API isn't quite the same as running P4 from the
command line. The
options are different and the output can be different.
 
However, take a look at the P4::Tagged method. This will put
all of your
output into Tagged format. Tagged format is the same as
using "-ztag" global
argument for the "p4" command (see "p4
help undoc") and can be helpful when
parsing output. Here's an example of the Tagged output for
the describe
command vs.. the regular output:
 

	$ p4 describe -s 5519  #Normal Output
	Change 5519 by nbk55mmnbk55mm-root-default
<mailto:nbk55mmnbk55mm-root-default>  on 2006/02/15
11:21:05
	 
	        Column width resize for the strike prices
	 
	Affected files ...
	 
	...
//depot/main/Components/MarketAnalyticsAndPricing/MarketMake
r/OptionGrid.cs#
82 edit
	...
//depot/main/Components/MarketAnalyticsAndPricing/MarketMake
r/OptionGrid.res
x#17 edit
	
	$ p4 -ztag describe -s 5519   #Tagged Output
	... change 5519
	... user nbk55mm
	... client nbk55mm-root-default
	... time 1140020465
	... desc Column width resize for the strike prices
	 
	... status submitted
	... depotFile0
//depot/main/Components/MarketAnalyticsAndPricing/MarketMake
r/OptionGrid.cs
	... action0 edit
	... type0 ktext
	... rev0 82
	... depotFile1
//depot/main/Components/MarketAnalyticsAndPricing/MarketMake
r/OptionGrid.res
x
	... action1 edit
	... type1 ktext
	... rev1 17
	

As you can see, the tagged output puts the field name in
front of every
line. This makes it much easier to parse your output.  If
you combine
P4::Tagged with P4::ParseForms, each line becomes part of a
Perl hash which
makes it even easier to work with these commands.

Remember you can always forgo the entire P4Perl API and
simply embed P4
commands directly into your program. This is what I have to
do because I am
unable to get the API installed on my Solaris Perforce
server (it's a long
story). Below gives you an idea what I go through in order
to do it this
way:

	#
	#   ####Perl Modules
	#
	 
	use Getopt::Long;       #Command Line Options Handling
Module

	#
	#   ####Constants
	#
	
	*P4_PORT = \"localhost:1666";
	    our $P4_PORT;
	*P4_COMMAND = \"/local/bin/p4";
	    our $P4_COMMAND;
	*P4_USER = \"perforce";
	    our $P4_USER;
	
		 
	#
	#   ####Get Command Line Parameters
	#
	
	my($p4Cmd, $p4User, $p4Password, $p4Port, $displayHelp);
	 
	GetOptions (
	    "command=s"     => \$p4Cmd,
	    "user=s"        => \$p4User,
	    "password=s"    => \$p4Password,
	    "port=s"        => \$p4Port,
	    "help"          => \$displayHelp
	) or die "Invalid Command Line Parameters\n";
	
		#
	#   ####Set the parameters for the Perforce Command
	#
	
	$p4Cmd        = $P4_COMMAND    unless ($p4Cmd);
	$p4User       = $P4_USER       unless ($p4User);
	$p4Port       = $P4_PORT       unless ($p4Port);
	
	if ($p4Password) {
	    $p4Cmd .= "-u $p4User -P $p4Password";
	} else {
	    $p4Cmd .= " -u $p4User";    #Use Password
Ticket
	}
	if ($p4Port) {
	    $p4Cmd .= " -p $p4Port";
	}
	
		#
	#   ####Now, Run Your Program
	#
	
	my $changeList = 69505;
	
	my $cmd = qq($p4Cmd -s describe -s $changeList);
	open (CHANGELIST, qq($cmd|)) or die qq(Can't run
"$cmd"\n);
	 
	while (<CHANGELIST>) {
	    #process it
	}
	
 
 
--
David Weintraub
david.weintraubbankofamerica.com
david.weintraubbofasecurities.com
 

________________________________

	From: p4perl-bouncesperforce.com
[mailto:p4perl-bouncesperforce.com] On Behalf Of
daniel.jacobssymbian.com
	Sent: Wednesday, February 15, 2006 10:25 AM
	To: p4perlperforce.com
	Subject: [p4perl] Using global options with P4Perl.
	
	

	Hi guys, 
	
	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: 
	text: 
	text: 
	text: 
	text: 
	text: 
	text: 
	text: 
	text: 
	text: 
	text: 
	text: 
	info1: 
	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? 
	
	Dan 

	________________________________

		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, bond, 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 postmastersymbian.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.
************************************************************
********** 
_______________________________________________
p4perl mailing list
p4perlperforce.com

http://maillist.perforce.com/mailman/listinfo/p4perl
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )