Solved

Write to file

Posted on 2000-03-30
8
132 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
Comment Utility
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
Comment Utility
Werkt ok niet!!!
0
 
LVL 4

Expert Comment

by:binkzz
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 4

Expert Comment

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

tom@power.net.uk
0
 
LVL 16

Expert Comment

by:maneshr
Comment Utility
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
Comment Utility
This will solve your problem:

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

Author Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 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

11 Experts available now in Live!

Get 1:1 Help Now