#!/usr/bin/perl $file = @ARGV[0]; $out_file = $file.".out"; my $count = 0; print "Processing file: $file\n"; print "Output file: $out_file\n"; open FILE, "$file" or die "cannot open $file file"; open OUT, ">>$out_file" or die "cannot create $out_file file"; #go through the file rows while () { chomp; # if row contain non-ASCII symbols - it is counted if ($_ =~ /[[:^ascii:]]/) { print "String before modification:\n $_ \n"; s/[[:^ascii:]]/q{<} . unpack(q{H2}, $1) . q{>}/eg; print "String after modification:\n $_ \n"; print OUT "$_\n"; $count++ ; } else { print OUT "$_\n"; } } print "there are $count possibly corrupted rows\n"; close FILE; close OUT;