On Fri, 25 Mar 2005 14:07:02 -0800, Kyle Lampe wrote:
> 
> while ( $lineFile1 = <XMLFILE1> && $lineFile2 = <XMLFILE2> ) {

[...snip...]

> But it's complaining about my &&.  How can I increment the contents of
> 2 files like this at once?
> 

According to "perldoc perlop", the && operator has higher precedence
than the assignment operator, "=". So what you really wrote is:
   while ( $lineFile1 = (<XMLFILE1> && $lineFile2) = <XMLFILE2> ) {
which is of course not what you meant. Always check operator precedence!
The solution is to either use "and", or use parenthesis to spell out
exactly what you want. In any case, if running under "use warnings"
(or "-w"), you would get a warning about this construct if you don't
use "defined", so it is best if you also added that also:
   while ( defined($lineFile1 = <XMLFILE1>) && defined($lineFile2 =
<XMLFILE2>) ) {

Needless to say, if you're not running under "use strict;" and "use
warnings;" you're doing a very bad thing... ;-)

Hope this helps,
-- 
Offer Kaye

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to