Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: open(F1,"+>>$FILE") works on Solaris,AIX but not Linux??

by pfaut (Priest)
on Feb 24, 2003 at 21:59 UTC ( [id://238254]=note: print w/replies, xml ) Need Help??


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';

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://238254]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-25 19:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found