pavanmach has asked for the wisdom of the Perl Monks concerning the following question:
my program is as under:
now the two files are as under: file1.txt#!/usr/bin/perl my ($file1,$file2); open(FILE1,"<$ARGV[0]"); open(FILE2,"<$ARGV[1]"); while(<FILE1>) { chomp($_); $file1 = $_; $file1=~s/\s+//; #print "$file1 \n"; while(<FILE2>) { print "<$file1> \n"; } }
In the above program i have two while statements. I am trying to print file1 variable in first while which is successful and the output is as under:haai hru welcome hello thats gr8 select * from emp; file2.txt haai hru welcome hello thats gr8 select * from emp; select * from dual;
while i am tring to print the same $file1 in second while statement statement the output is :haai hru welcome hello thatsgr8 select* from emp;
I am not able to access the variable ($file1) in second while loop. Why so? How can i overcome the problem ?<> <> <> <> <> <>
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Accessing variables
by Utilitarian (Vicar) on Feb 02, 2010 at 08:08 UTC | |
Re: Accessing variables
by Anonymous Monk on Feb 02, 2010 at 07:30 UTC | |
by pavanmach (Novice) on Feb 02, 2010 at 08:15 UTC | |
by Krambambuli (Curate) on Feb 02, 2010 at 08:52 UTC | |
by pavanmach (Novice) on Feb 02, 2010 at 11:52 UTC |
Back to
Seekers of Perl Wisdom