Gary Stainburn said:
> On Tuesday 05 November 2002 5:37 pm, LRMK wrote:
>> there is a   one problem
>> $mail{message}=<FIN>; only reads the first line of the file
>> in the following block;
>>
>>  $oldsep=$/; $/=undef; disable line seperation
>>  open(FIN,"<myfile>")||die "cannot open file: $!\n";
>>  $mail{message}=<FIN>;
>>  close(FIN);
>>  $/=$oldsep;
>
> This is not the case. The statement:
>
> $mail{message}=<FIN>;
>
> will start at the beginning of the file sucking in characters until it
> reaches  the first $/ character.  Normally this would be the 1st newline
> - i.e. the  whole of the 1st line.  Beause I've UNDEF'd $/ it won't stop
> until it reaches  the EOF.
>
> I then restore $/ before proceeding.

As a matter of style, this is one of the few places where using local is
sensible and correct:

  {
      local $/;
      open FIN, $file or die "cannot open $file: $!\n";
      $mail{message} = <FIN>;
      close FIN or die "cannot close $file: $!\n";
  }

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to