Solved

Write to file

Posted on 2000-03-30
8
135 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
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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 100 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

Suggested Solutions

Title # Comments Views Activity
Perl for loop for 2000 ms 7 105
delete query using perl dbi 3 109
Filtering a file to table 9 101
Insert Text into odbc.ini file 15 67
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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…

808 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