my @warning_array; print "Enter input file (.RTF)\n"; $infile = ; chomp($infile); print "Enter output file (.RTF)\n"; $outfile = ; chomp($outfile); #Open selected files open my $fh, "<", $infile; open my $output, ">", $outfile; #New RTF writer my $rtf = RTF::Writer->new_to_file($outfile); no warnings 'uninitialized'; #New RTF -> text converter my $object = RTF::TEXT::Converter->new (output => \$string); $object->parse_stream( $fh ); #Create the array and push the text into it my @un = split("\n", $string); #Sort the array my @sorted = sort { my @fields_a = split / / , $a; my @fields_b = split / /, $b; chomp($a, $b); $fields_a[1] cmp $fields_b[1] || $fields_a[0] <=> $fields_b[0]; } @un; #SEARCH FOR WARNINGS @warning_array = grep {$_ =~ 'WARNING'} (@sorted); foreach(@warning_array){ if ($_ =~ "WARNING"){ $rtf->prolog( 'title' => "Color Test", 'colors' => [ undef, [0,0,0], # 1 - black [255,0,0], # 2-red [0,255,0], # 3-green [0,0,255], # 4-blue [255,128,0], # 5-orange [255,255,0], # 6-yellow ], ); #PRINT WARNINGS IN YELLOW $rtf->printf( \'{\fs20\lang1036\noproof\cf5\chshdng10000\chcbpatN\chcfpatN\cbN %s} \par ', "$_"); } } }