http://www.perlmonks.org?node_id=840914

perl_seeker has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Format statement and 'if' loop
by Fletch (Bishop) on May 20, 2010 at 13:00 UTC

    == is for numeric comparisons; you mean eq. Go read perlop.

    Additionally: It doesn't really make any sense to close your output handle and then go on to process more rows. You probably want to use last to exit the loop and then close and print your footer outside.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: Format statement and 'if' loop
by marto (Cardinal) on May 20, 2010 at 13:08 UTC
Re: Format statement and 'if' loop
by BrowserUk (Patriarch) on May 20, 2010 at 13:01 UTC
       if ($subdvn=='KP' && $tow=='RP' && $phase=='1' )

    Probably that you are using numeric == to compare strings.

    Of course, if you use strict & warnings, you'd now that already.

Re: Format statement and 'if' loop
by moritz (Cardinal) on May 20, 2010 at 13:13 UTC
    By the way there is no 'if' loop.

    if is a branching construct, not a loop. You can also say 'if' statement.

Re: Format statement and 'if' loop
by Krambambuli (Curate) on May 20, 2010 at 13:05 UTC
    Try

    if ($subdvn eq 'KP' and $tow eq 'RP' and $phase eq '1' )

    instead of

    if ($subdvn=='KP' && $tow=='RP' && $phase=='1' )


    Krambambuli
    ---
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Format statement and 'if' loop
by Anonymous Monk on May 20, 2010 at 12:58 UTC
    What is the mistake here?

    You keep doing the same thing and expecting a different output.