in reply to open(F1,"+>>$FILE") works on Solaris,AIX but not Linux??
An open with mode '>>' should position to end of file. You need to seek to the beginning in order to read from the file. I added two lines to your program and it now appears to work as you would like it to.
#!/usr/local/it/bin/perl -w # # Create sample file with two # instances of "FAILED" string # use Fcntl qw(SEEK_SET); $RFILE="example_file"; open(F1,">$RFILE") or die "cannot open $RFILE for creation!\n"; print F1 "FAILED\nPASSED\nPASSED\nFAILED\nPASSED\n"; close(F1); # # Open file for Append AND read # open(RESULT,"+>>$RFILE") or die "cannot open $RFILE\n"; seek RESULT,0,SEEK_SET; # # Set an array to the filehandle and count the # number of lines with the "FAILED" string # my @result_array = <RESULT>; $number_failures = grep /FAILED/, @result_array; # # Overall status is FAILED if any "FAILED" strings # are found # $OVERALL_STATUS = ($number_failures > 0) ? "FAILED":"PASSED"; print "+-------------------+\n"; print "| |\n"; print "| EO_FAIL_03 $OVERALL_STATUS |\n"; print "| |\n"; print "+-------------------+\n"; close(RESULT); <code>--- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';
|
|---|