Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Write to file

Posted on 2000-03-30
8
Medium Priority
?
140 Views
Last Modified: 2010-03-05
Hello,

I have the following HTML part:

<textarea cols="90%" cols="40" rows="15" name="database" wrap="off">orderinfo|Order Informatie van Ordernummer|
orderinfo|Order Informatie van Ordernummer|
MainPage|<u>S</u>tart pagina|
User|Gebruiker|
LoginLogout|<u>L</u>ogin/Logout|
Products|Produkten|
Orders|Opdrachten|
Archive|Archief|
View|Bekijken|
Edit|Aanpassen|
</textarea>

I use the following script (Part of) to write to a file:

      @database = $r_in->{'database'};
      $database = "$datalang/$r_in->{'trans_dir'}/$r_in->{'trans_lang'}.lang";
      open (DATABASE, ">$database");
      foreach $line (@database) {
            chop($line);
            print DATABASE "$line";
      }
      close (DATABASE);

$datalang/$r_in->{'trans_dir'}/$r_in->{'trans_lang'}.lang is the path to the file.

The file is writen but after each lien I get an empty line in the file??

orderinfo|Order Informatie van
Ordernummer|

orderinfo|Order Informatie van Ordernummer|

MainPage|<u>S</u>tart pagina|

User|Gebruiker|

LoginLogout|<u>L</u>ogin/Logout|

Products|Produkten|

Orders|Opdrachten|

Archive|Archief|

View|Bekijken|

Edit|Aanpassen|

How to solve this problem??
I do not want that??
 
0
Comment
Question by:mmcw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 4

Expert Comment

by:binkzz
ID: 2668714
Probeer :

chomp $line;

ipv:

chop $line;


Chop haalt altijd de laatste letter van een regel af, of het een eol character is of niet. Chomp haalt alleen en alle eol characters van het einde van een regel. Een geposte textarea heeft twee eol characters, \r en \n.

Binkzz
0
 

Author Comment

by:mmcw
ID: 2668753
Werkt ok niet!!!
0
 
LVL 4

Expert Comment

by:binkzz
ID: 2668761
hm...

probeer iets als:

while ($line =~ m/\r$/s)
{
  $line =~ s/\r$//;
}

while ($line =~ m/\n$/s)
{
  $line =~ s/\n$//;
}

'Tis misschien wat onhandig maar we moeten eerst het probleem zien te vinden.

Binkzz
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mmcw
ID: 2668965
Dat werkt ook niet!
Ik download de text file die gecreert wordt met cuteftp. In homesite verschijnt de extra lege regel wel als ik het bestand een keer heb weggescreven.

Het vreemde is echter dat als ik deze gevens weer ophaal in het formulier (textarea) verschijnt die extra lege regel niet. (Gebruik makende van een ander deel van het script!!)

Echter wanneer ik deze file, gebruikmakende van cuteftp download om te bekijken (In kladblok) verschijnt deze extra lege regel ook niet!!
0
 
LVL 4

Expert Comment

by:binkzz
ID: 2669008
Als je me het hele script opstuurt zal ik een kijkje nemen.

tom@power.net.uk
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2669485
gentlmen, can we have the converstion in Eng please. Although, it seems the problem might be solved, we would like to understand it too.

Thanks.
0
 
LVL 5

Accepted Solution

by:
PC_User321 earned 300 total points
ID: 2670639
This will solve your problem:

$line =~ s/[\s\n\r]*$//;
0
 

Author Comment

by:mmcw
ID: 2776507
I had to upload my file not in asci mode but binari mode also!!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question