Loading ...
Sorry, an error occurred while loading the content.

Input/Output and all that jazz

Expand Messages
  • gaijin_punch
    First - thanks to those that helped me w/ Net::SMTP. Just an FYI - I got the auth() to work, but turns out it wasn t needed --- I think this is a problem on
    Message 1 of 1 , Apr 30, 2003
    • 0 Attachment
      First - thanks to those that helped me w/ Net::SMTP. Just an FYI - I
      got the auth() to work, but turns out it wasn't needed --- I think
      this is a problem on my ISPs side, as they definitely said that SMTP
      requires authorization. Oh, well, not my problem for now.

      Anyways, I think I know the answer to this question, but I'll cut to
      the chase anyway. I did a quick review of the filehandles chapter in
      the furry mammal w/ an underbite book, which basically told me the
      basics. I understand we've got <, > and >> to denote what we want to
      do w/ a file. However, what if I had a wacky notion to read a file,
      and THEN write over it? Well, for the most part, opening a file with
      "open IN, myfile.txt" works except for two times:

      1) When the users finger slips and they hit CTRL-C instead of CTRL-D

      2) When the user doesn't use their head, and hits CTRL-C instead of CTRL-D

      Basically, CTRL-C makes this a 0-byte file. For the record, the user
      is putting some commands into STDIN. This could get extremely
      mundane, or they could get called to do something else, so basically
      the script reads in where they last left off, then writes back to the
      same file where they stop. If they hit CTRL-D, it works like a champ.
      CTRL-C, and everything is wiped out.

      I tried two ways:

      1: print out to the file after STDIN is finished (I understand why
      this one isn't writing to the file when killed)

      2: Then, I tried printing out to the file (not in append mode) within
      the STDIN loop, which effectly buffered what it was supposed to write
      each time, then when STDIN was done, printed it out X times in the file.

      I know I can do some trickery w/ temp files and swapping around and
      whatnot, but I'm wondering if there's a slick way of not having to do
      that.

      Thanks
    Your message has been successfully submitted and would be delivered to recipients shortly.