#!/usr/bin/perl print "This is test perl program\n"; open ( FILE1,"){ $i= s/apple/APPLE/; #just replacing apple with APPLE #this works fine if($i){ $test1=$_; } } close FILE1; print "test1 =$test1\n"; #this has the the whole line which is of #the form a b ($a,$b)=split(/\s/,$test1,2); print "b=$b\n"; open (FILE2,"){ $i= s/$b/MANGO/e; # This part doesn't work print $_; if($i){ $test2=$_; } } close FILE2; #print "$test2"; ($c,$d)=split(/\s/,$test2,2); print "d= $d\n"; #### ap878ple mango 1apple me45ango a4pple mat5ngo apple mango a2pple ma43ngo a4pple mat5ngo #### mandfgo andwefrwehra maafweewngo andhvwera mango pineapple masvffngo anewfwdhra