while loop perl

I am trying to create a success and fail as below in a perl script :

while echo$? is 2 it should append as below to .fail file

=====================

    if ( open(IN, "$outputfile"))
    {
        while( $my_line = <IN> )
        {
	#print "$my_line \n" ;
                return 0;
        }
        system("echo \"FA_PATCH_CHECK failed on $node $vm:\" >> $INITDIR/$RAND/FA_PATCH_CHECK.fail");
        return 2;

    }

======

I am not able to see this file, is there a better way to do ?

Please advice.

---------- Post updated at 05:41 AM ---------- Previous update was at 03:54 AM ----------

"$outputfile" above is a command which is being run:

Just a simple question

if command successfull then .sucess file gets created , if command not exists or unsucessfull switch used then .diff file gets created

I can't discern what you're even trying to do.

$outputfile is a command? Why is it called $outputfile then? Can you tell me the actual value this variable holds?

$output=patchlist -report all
That runs a patch command, output is like 32 lines.

---------- Post updated at 03:02 AM ---------- Previous update was at 03:01 AM ----------

I choose to call it as output, since i am expecting the result from that command.

If that's all you want to do then check for the $? variable after executing your command. In Bash, for example -

<your_command>
if [ "$?" -eq 0 ]; then
 # create .success file
else
 # create .diff file
fi

tyler_durden