473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Write to File question

von
I am writing data from a Javascript to a text file using a Perl script and
it all works pretty well - except ...

This:

"Here is my data"

becomes:

"Here%20is%20my%20data" when it gets to the text file.
Is there a way to replace the "%20" for a normal space as the Perl script
writes it to file??

Thanks. :)
Jul 19 '05 #1
8 6244
von wrote:
I am writing data from a Javascript to a text file using a Perl


Somewhere you are not telling us something because taking your description
literally it doesn't make any sense.
What are you doing?

jue

Jul 19 '05 #2
von
I am running a Javascript that generates a piece of data.

I am then sending this data to a text file via a Perl script.

Somewhere along the way the spaces in-between the data are changed to
"%20" - and I would like to change them back to spaces to make it easier to
read.

:)

"Jürgen Exner" <ju******@hotmail.com> wrote in message
news:qAfQd.18798$uc.16755@trnddc05...
von wrote:
I am writing data from a Javascript to a text file using a Perl


Somewhere you are not telling us something because taking your description
literally it doesn't make any sense.
What are you doing?

jue

Jul 19 '05 #3
[Top-posting fixed, please don't do that]
von wrote:
"Jürgen Exner" <ju******@hotmail.com> wrote in message
news:qAfQd.18798$uc.16755@trnddc05...
von wrote:
I am writing data from a Javascript to a text file using a Perl
Somewhere you are not telling us something because taking your
description literally it doesn't make any sense.
What are you doing?

I am running a Javascript that generates a piece of data.
I am then sending this data to a text file via a Perl script.
Saying the same thing again in the same way doesn't really help
understanding.
Trying to rephrase, please correct me if I missunderstood:
You have a Javascript, that sends data to a Perl script, which in turn
writes the data to a file.

If this is correct then you didn't tell us anything about _HOW_ the data is
transmitted between the JavaScript and the Perl script. And obviously that
is the crucial point.
Somewhere along the way the spaces in-between the data are changed to
"%20" - and I would like to change them back to spaces to make it
easier to read.


But you didn't tell us what the way is.... :-(

jue
Jul 19 '05 #4
von
Okay - let me start over. :)

I have a Javascript that generates a piece of information that I want
written to a file on my server.

I used this in the Javascript to send it to a Perl Script:
_________________________________
var i=new Image();

i.src="http://www.mydomain.com/cgi-bin/write.pl?" + user;

______________________________________
Then I use the following Perl script (write.pl) to send the data to my text
file:
________________________________
#!/usr/bin/perl

use CGI::Carp qw( fatalsToBrowser );
$isdata= $ENV{QUERY_STRING};

# Set $data_file to the location and name of the file in question.
my $data_file = '/usr/home/mydomain/public_html/data1.txt';

open (DATA, "+>>$data_file") or die "can't open $data_file $!";
print DATA "$isdata";

{
print "$_\n";
}
close (DATA);
__________________________________

My problem is that the data arrives to the text file with '%20' in place of
the spaces.

ie: "This%20is%20the%20data"

I would like the '%20' converted back to spaces.

I have been playing with 'unescape()' but I can't seem to get it to work
(user error I'm sure).

Any help would be appreciated.

:)

Jul 19 '05 #5
In article <1b********************@comcast.com>, von <vo*@vonvon.com>
wrote:
Okay - let me start over. :)

I have a Javascript that generates a piece of information that I want
written to a file on my server.

I used this in the Javascript to send it to a Perl Script:
_________________________________
var i=new Image();

i.src="http://www.mydomain.com/cgi-bin/write.pl?" + user;

______________________________________
Then I use the following Perl script (write.pl) to send the data to my text
file:
________________________________
#!/usr/bin/perl

use CGI::Carp qw( fatalsToBrowser );
$isdata= $ENV{QUERY_STRING};

# Set $data_file to the location and name of the file in question.
my $data_file = '/usr/home/mydomain/public_html/data1.txt';

open (DATA, "+>>$data_file") or die "can't open $data_file $!";
print DATA "$isdata";

{
print "$_\n";
}
close (DATA);
__________________________________

My problem is that the data arrives to the text file with '%20' in place of
the spaces.

ie: "This%20is%20the%20data"

I would like the '%20' converted back to spaces.


$isdata =~ s/%20/ /g

You can also try the query_string() method of the CGI module, but I
can't tell from the docs whether that decodes the URL encoding or not.

FYI: this newsgroup is defunct. Try comp.lang.perl.misc in the future.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jul 19 '05 #6
von wrote:
Okay - let me start over. :)

I have a Javascript that generates a piece of information that I want
written to a file on my server.

I used this in the Javascript to send it to a Perl Script:
_________________________________
var i=new Image();

i.src="http://www.mydomain.com/cgi-bin/write.pl?" + user;


Sorry, can't help you with that. Never used Perl in a CGI environment.

But I heard of some URI::decode or something similar to that on CPAN.

jue
Jul 19 '05 #7
von
Jim Gibson wrote:

(snip)

FYI: this newsgroup is defunct. Try comp.lang.perl.misc in the future.

Thanks Jim :)
Jul 19 '05 #8

"von" <vo*@vonvon.com> wrote in message
news:1b********************@comcast.com...
Then I use the following Perl script (write.pl) to send the data to my
text file:
________________________________
#!/usr/bin/perl

use CGI::Carp qw( fatalsToBrowser );
$isdata= $ENV{QUERY_STRING};
open (DATA, "+>>$data_file") or die "can't open $data_file $!";
print DATA "$isdata";
My problem is that the data arrives to the text file with '%20' in place
of the spaces.

ie: "This%20is%20the%20data"


You can do this kind of thing using your own code, but the best way to do it
is to use the functions provided by the Carp module.

Start with
use CGI;

and have a look at the documentation for it - it's a much better way to do
things than to process STDIN "manually", since someone else has already
written the code you need to do the job. Any beginner's tutorial online
that talks about perl and CGI will tell you what to do.

Matt
Jul 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: lawrence | last post by:
I'm probably missing something obvious, but I'm unable to write a file with this function. I've used my FTP software to set permissions to 777 on all the files in question. I've tried r, r+, w, and...
3
by: burdeen | last post by:
I can't find any way of writing a unicode, or UTF-8 format text file. Right now i have a Unicode string that i write to the text file and the unicode characters are replaced with ANSI question...
11
by: Russ | last post by:
My web app writes some binary data to a file at the client site via Response.Write and Response.BinaryWrite. This action is accomplished in response to a button click, with C# code behind as...
5
by: Arvind P Rangan | last post by:
Hi, i like to read an existing xml file which has a schema defined to it, and then write or add data to the existing xml file using vb.net/c#. May be this Question has been answered earlier....
5
by: philip | last post by:
Here is some lines of code than I wrote. You can copy/paste theis code as code of form1 in a new project. My problem is this one : I try to write in a file a serie of bytes. BUT some bytes...
2
by: key9 | last post by:
Hi all look at the organize tree main.c ------ #include lib_adapter.c main() { foo();
14
by: Frank | last post by:
I see that ImageFormat includes exif. But I can't find out if I've System.Drawing.Image.FromStream or something like it can read and/or write that format.
3
by: golden | last post by:
Hello, I am going to ask a question regarding write and lseek. I will provide code at the end of this, but first some background. I am trying to identify the cause of some latency in...
20
by: cscorley | last post by:
For some reason, I cannot use fopen() on the file in write mode. The file "time" is in the same directory as the .php file, with permissions set to 0766. PHP Version 5.2.5 Apache/2.2.8 code...
3
by: Ben Keshet | last post by:
I have a probably simple beginner's question - I have a script that I am currently able to print its output. instead, i want to write it into a file - I tried different versions of write() but...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.