in reply to Nested While loop not working

Try this code ;) Have to come out of the second loop after the line has been printed so that the line will be queued out. it can be done using... last;
#!/usr/bin/perl use strict; open(FILE1,"abc"); open(FILE2,"def"); while (my $name1=<FILE1>) { chomp($name1); while (my $name2=<FILE2>) { chomp($name2); print "Line1: $name1 | Line2: $name2 \n"; last; } } close(FILE1); close(FILE2);