Fw: [p4perl] sync problems
Roger Day
roger.day at globalgraphics.com
Mon Mar 14 16:28:26 PST 2005
you are correct. You think you know a language, then it still manages to
bite u in the foot. Doh!
Doesn't help me with my main problem in that the files still aren't being
transferred to the new root.
Roger
Tony Smith <tony at smee.org>
14/03/2005 18:15
To: p4perl at perforce.com
cc: "Roger Day" <roger.day at globalgraphics.com>
Subject: Re: Fw: [p4perl] sync problems
On Monday 14 March 2005 17:09, Roger Day wrote:
> It's the same as before, except now:
>
> $#warnings == -1
>
> Roger
How's 'warnings' declared? $# operates directly on an array, not on a
reference to an array. i.e.
@warnings;
printf( "length = %d\n", $#warnings );
produces:
length = 0
But:
$warnings = $p4->Errors();
printf( "length = %d\n", $#warnings );
produces:
length = -1
Look familiar? In P4Perl it might look something like this:
#!/usr/bin/perl
use P4;
my $p4 = new P4;
my $errors = $p4->Errors();
my $warnings = $p4->Warnings();
printf( "%d (%d) errors\n", $#errors, $p4->ErrorCount() );
printf( "%d (%d) warnings\n", $#warnings, $p4->WarningCount() );
and this produces:
-1 (0) errors
-1 (0) warnings
This is because the $# operator is looking for @errors and @warnings,
neither
of which have been defined. All brought to you through the joy of perl's
context-awareness....
If you make sure that @warnings and @errors are declared as arrays:
#!/usr/bin/perl
use P4;
my $p4 = new P4;
my @errors = $p4->Errors();
my @warnings = $p4->Warnings();
printf( "%d (%d) errors\n", $#errors, $p4->ErrorCount() );
printf( "%d (%d) warnings\n", $#warnings, $p4->WarningCount() );
You get:
0 (0) errors
0 (0) warnings
which is what you'd expect.
Tony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://p4tress.perforce.com/pipermail/p4perl/attachments/20050314/c5df7bd5/attachment.html
More information about the p4perl
mailing list