[EMAIL PROTECTED] writes:
 > Hi,
 > 
 > I have the following routine to remove all "\n" characters from a strings
 > end before writing it to a file. within the routine I get the following
 > error when a "\n" is removed. Everything is working as expected, but the
 > error irritates me a bit. 
 > The code:
 > 
 > sub config_save {
 >      if (!(-d $configpath)) {
 >              print "Created Path!\n";
 >              mkpath [$configpath];
 >      }
 >      open CONFIG, ">$configpath"."$configfile";
 >      $config=$configtext->get(0.1,"end");
 >      while (chomp $config) {redo unless eof;}
 >      print CONFIG $config;
 >      close CONFIG;
 >      $configwindow->destroy;
 > }
 > 
 > The Error:
 > 
 > Filehandle CONFIG opened only for output at vasmap.pl line 78, <CONFIG> line
 > 2.

I think the problem is eof not chomp. In fact its not clear why redo
and eof are there at all. If all you want to do is remove trailing
newlines (or more precisely input record separators)  then

         while (chomp $config) {}

would have done. If you wanted to remove trailing white space then

      $config =~ s/\s+$//;

should do the trick.

HTH

-- 
Brian Raven

Well, I think Perl should run faster than C.  :-)
             -- Larry Wall in <[EMAIL PROTECTED]>


-----------------------------------------------------------------------
The information contained in this e-mail is confidential and solely 
for the intended addressee(s). Unauthorised reproduction, disclosure, 
modification, and/or distribution of this email may be unlawful. If you 
have received this email in error, please notify the sender immediately 
and delete it from your system. The views expressed in this message 
do not necessarily reflect those of 
LIFFE Holdings Plc or any of its subsidiary companies.
-----------------------------------------------------------------------

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to