On Jul 16, Kevin Old said:

>I'm trying to get this line to work
>
>(!$opt_Z) ? die "Must supply Market\n" : $mkt = $opt_Z;
>
>and I keep getting compiler errors.

You should reproduce the error so we don't have to, but I know the error
already.  Something like "cannot modify die in assignment"?

The ?: operator binds more tightly than the = operator, so your code reads
like

  (!$opt_Z ? die "..." : $mkt) = $opt_Z;

This makes Perl think you're going to assign to either $mkt or the return
value of die(), and the latter is impossible.

Either parenthesize the assignment:

  !$opt_Z ? die "..." : ($mkt = $opt_Z);

or swap the two:

  $opt_Z ? $mkt = $opt_Z : die "...";

Or better yet, use the following idiom:

  $mkt = $opt_Z or die "...";

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to