in reply to Re: Nested While loop not working
in thread Nested While loop not working

Hi I have tried it (the thing is when i remove second loop its printing the $line value )

Replies are listed 'Best First'.
Re^3: Nested While loop not working
by vinoth.ree (Monsignor) on Mar 11, 2014 at 09:43 UTC

    No, Your code is working for me without removing the second loop.

    use strict; use warnings; open(file_one,"<","ABC")or die $!; while(my $line = <file_one>) { open(file_two,"<","CDE") or die $!; while(my $line2=<file_two>) { print "line : $line line2 : $line2 \n"; } close(file_two); }

    line : test
    line2 : CDE

    line : test
    line2 : CDEEE

    line : test
    line2 : CDEEEE

    line : test121212121
    line2 : CDE

    line : test121212121
    line2 : CDEEE

    line : test121212121
    line2 : CDEEEE

    line : adskjdsadjdka
    line2 : CDE

    line : adskjdsadjdka
    line2 : CDEEE

    line : adskjdsadjdka
    line2 : CDEEEE

    Update:

    Added file content.

    ABC:

    test
    test121212121
    adskjdsadjdka

    CDE:

    CDE
    CDEEE
    CDEEEE


    All is well