in reply to Not hard-code text with NET::SMTP ?

$newline will be the last line of staging.log, which you are getting in a very inefficient way. Is that what you want?

Abigail

Replies are listed 'Best First'.
Re: Re: NET::SMTP
by Bush Dr (Initiate) on Aug 11, 2003 at 15:51 UTC
    that's the way I've done it now. It will be the only line in that file. I'm using:
    open (PAGE, "<staging.log");
    any ideas?

      I suspect that staging.log is playing tricks on you, but having a blank line at the end of the file. You can always check if the contents of the current instance of $line is empty before you assign it to $newline.

      Something like this:

      if( $line =~ /^\s*$/ ) { $newline = "Blank line."; } else { $newline = $line; }

      Or, better yet, you could play around with debug mode and step through the program as it runs.

      elbieelbieelbie

      If you're sure that's the only line in the file, a simpler and perhaps less error-prone method is to use:

      $newline = join("",<PAGE>);
      which will read in all of the lines from the file and concatenate them into one string.

      In any case, printing out $newline as a debugging aid will probably help you track this problem down without sending a zillion messages.

Re: Re: NET::SMTP
by jonnyfolk (Vicar) on Aug 11, 2003 at 19:35 UTC

    No one took the bait, so I will :)

    What would be a more efficient way of doing it?

      One way of doing it more efficiently:
      while ($newline = <HANDLE>) {}

      It's very inefficient to first read in all the lines into an array, and then setting $newline to each entry of the array, ending at the last.

      If the file is big, you might want to read backwards from the end.

      Abigail