in reply to Re: Close command not being honored
in thread Close command not being honored

Thanks Corion. I didn't write this script. I really don't know anything about Perl to be honest with you. However, I was under the impression that this command was to close the filehandle:

$SNF_fh->close ||

If not, what does that command do? Also, What is the correct line of code to use to close the filehandle that was open? Again, thank you so much for your response.

Replies are listed 'Best First'.
Re^3: Close command not being honored
by Corion (Patriarch) on Feb 21, 2014 at 16:01 UTC

    The code

    $SNF_fh->close

    closes the filehandle $SNF_fh.

    But further up, the call to tempfile returns a filehandle that you store in the variable $fh. You never show where $fh is closed.

    If you are not interested in the filehandle and only in the name of the tempfile, immediately closing the filehandle returning from it is the sanest approach:

    my ($fh, $filename) = tempfile( DIR => $self->{Temp_Dir} ); close $fh; # we only want the filename
      Corion.. I can't thank you enough! That fixed my issue! You are wonderful!! I have been working on this for months with no luck. That was such a simple fix! Like I explained, I don't know much about Perl at all. Thanks to you, I can stop pulling my hair out.
      Corion, on the day you gave me this answer, it resolved my issue. I replied back to you, thanking you profusely for your help. I see that my reply never was posted so I wanted to take this time to make sure that you saw my "thank you!!". I had been struggling with that problem for a few weeks and you solved it in 3 seconds. That is why you are a PerlMonk and I'm a confused user. Again, I appreciate the help more than you know. Sincerely, thank you.