my $flag = 1; if ( -e $file1 ) { print "Script '$file1' already exists\n"; open(FILE1,"$file1"); my @seq1 = ; close FILE1; # @seq2 contains the contents of the file to generated. my $diff = Algorithm::Diff->new( \@seq1, \@seq2 ); my $sep; my $flag = 1; $diff->Base( 1 ); # Return line numbers, not indices while( $diff->Next() ) { next if $diff->Same(); if( ! $diff->Items(2) || ! $diff->Items(1) ) { $flag = 0; print $diff->Get(qw( Min1 Max1 Max2 )),"\n"; } else { $flag = 0; $sep = "---\n"; print $diff->Get(qw( Min1 Max1 Min2 Max2 )),"\n"; } print "< $_" for $diff->Items(1); print $sep; print "> $_" for $diff->Items(2); } if($flag == 0) { print "User edits,do u want to overwrite the exisiting $file1?"; print "[INFO] Continue ? [no]"; my $answer = ; chomp $answer; if ($answer =~ /^n/i) { print"Not Generated the script '$file1'"; } ....