Solved

Write to file

Posted on 2000-03-30
8
133 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
remove duplicates from the csv file 13 100
Any syntax error for this clone.plscript 6 132
Perl Awk Need Help 3 109
Union rows in array that have common elements 2 89
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…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

929 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now