[p4] perl trigger

Ken.Williams at thomson.com Ken.Williams at thomson.com
Tue Nov 21 16:13:23 PST 2006


 

> -----Original Message-----
> From: perforce-user-bounces at perforce.com 
> [mailto:perforce-user-bounces at perforce.com] On Behalf Of David Alban
> Sent: Friday, November 17, 2006 11:55 AM
> To: perforce-user at perforce.com
> Subject: Re: [p4] perl trigger
> 
> > You've got an operator precedence problem there.  Change to this:
> > 
> >    @FILES = `ls -l /perforce/triggers` or die("Bombed");
> > 
> > Or this:
> > 
> >   (@FILES = `ls -l /perforce/triggers`) || die("Bombed");
> 
> There is no operator precedence problem in either statement. 
> Changing from the first statement above to the second does not change
> the behavior of the code.

The operator precedence problem was in the original code Rob posted:

  @FILES = `ls -l /perforce/triggers` || die("Bombed");


Try that in a one-liner and you'll see the problem:

% perl -le '@F = `ls -l` || die(); print "Files: ". at F'
Files: 1

% perl -le '@F = `ls -l` or die(); print "Files: ". at F'
Files: 96

There are 96 files in that directory, but the first version of the code
concatenates them into one big string because the precedence problem
forces a scalar context for the backticks.

 -Ken




More information about the perforce-user mailing list