Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Nested While loop not working

by choroba (Cardinal)
on Mar 11, 2014 at 08:58 UTC ( [id://1077816]=note: print w/replies, xml ) Need Help??


in reply to Nested While loop not working

Do you check Perl was able to open the files? Use or die
open my $file_one, '<', 'ABC' or die $!;

or, use autodie.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Nested While loop not working
by Manisha (Initiate) on Mar 11, 2014 at 09:10 UTC

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

      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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1077816]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-23 05:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found