Solved

Write to file

Posted on 2000-03-30
8
134 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

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 …
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

778 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