[p4] perl trigger

David Alban dalban at stubhub.com
Mon Nov 27 12:47:39 PST 2006

Mea culpa!  You did say:

  change this to ... or ...

Sorry!  I misread it as:

  change this ... to this ...

David Alban <dalban at stubhub.com>
Release Engineering Tools

-----Original Message-----
From: Ken.Williams at thomson.com [mailto:Ken.Williams at thomson.com] 
Sent: Tuesday, November 21, 2006 4:13 PM
To: David Alban; perforce-user at perforce.com
Subject: RE: [p4] perl trigger


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


More information about the perforce-user mailing list