[16673] in Perl-Users-Digest
Perl-Users Digest, Issue: 4085 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 21 18:11:04 2000
Date: Mon, 21 Aug 2000 15:10:41 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <966895841-v9-i4085@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 21 Aug 2000 Volume: 9 Number: 4085
Today's topics:
Re: Modifying a text file (Eric Bohlman)
Re: Modifying a text file <jeff@vpservices.com>
MS IIS and perl syntax errors causing download prompt <fchanny@lbl.gov>
Re: MS IIS and perl syntax errors causing download prom (Abigail)
Re: Net::Dns broken, gethostbyname OK dufalac@my-deja.com
Re: Net::SMTP SIZE from EHLO command <gellyfish@gellyfish.com>
newbie Q: debugging - how to <robsmiler@bigfoot.com>
Re: newbie Q: debugging - how to <care227@attglobal.net>
newbie question about "uninitialized variables" (Jon S.)
Re: newbie question about "uninitialized variables" <tina@streetmail.com>
Newbie: Help with Fork on NT box jonnydeja@my-deja.com
Re: Newbie: Help with Fork on NT box <latsharj@my-deja.com>
Re: newline and carriage return problems jonnydeja@my-deja.com
Re: newline and carriage return problems <eric.kort@vai.org>
Re: newline and carriage return problems <timewarp@shentel.net>
Re: newline and carriage return problems flanagab@hqamc.scott.af.mil
Re: newline and carriage return problems flanagab@hqamc.scott.af.mil
Re: newline and carriage return problems flanagab@hqamc.scott.af.mil
Re: newline and carriage return problems <timewarp@shentel.net>
Re: opening several files with the same file handle <davem@skantech.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 21 Aug 2000 18:10:06 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Modifying a text file
Message-Id: <8nrr9u$8sm$2@slb7.atl.mindspring.net>
Lincoln Marr (lincolnmarr@nospam.europem01.nt.com) wrote:
:
: "> You should seriously consider using DBD::CSV or DBD::RAM, which will
: > handle all the low-level mechanics of file maintenance for you; your code
: > will reduce to writing a few simple SQL INSERT, UPDATE, and DELETE
: > statements. And if your database ever gets so big that you need to go to
: > a full-fledged RDBMS, all you'll have to do is change one or two literal
: > strings in your code and it will still work.
: >
:
: But I am using a flat text file - don't sql databases interface to programs?
Most of them do, but these ones (as well as DBD::XBase and a few others)
are self-contained. DBD::CSV works only with flat text files; DBD::RAM
works with a wider range of file formats, but still can handle flat text
files.
: And can i still use these modules even with pipe delimited text files?
Yes.
------------------------------
Date: Mon, 21 Aug 2000 11:10:28 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Modifying a text file
Message-Id: <39A17094.7A53C653@vpservices.com>
Lincoln Marr wrote:
>
> "> You should seriously consider using DBD::CSV or DBD::RAM, which will
> > handle all the low-level mechanics of file maintenance for you; your code
> > will reduce to writing a few simple SQL INSERT, UPDATE, and DELETE
> > statements. And if your database ever gets so big that you need to go to
> > a full-fledged RDBMS, all you'll have to do is change one or two literal
> > strings in your code and it will still work.
> >
>
> But I am using a flat text file - don't sql databases interface to programs?
Some do, some don't.
> And can i still use these modules even with pipe delimited text files?
Yes. With DBD::CSV, you just set $dbh->{csv_sep_char}. With DBD::RAM,
you just declare the file to be of type 'PIPE'.
--
Jeff
------------------------------
Date: Mon, 21 Aug 2000 12:55:48 -0700
From: Frank Hanny <fchanny@lbl.gov>
Subject: MS IIS and perl syntax errors causing download prompt
Message-Id: <39A18944.44278F6E@lbl.gov>
Regarding the issue I raised previously of certain perl cgi syntax
errors resulting in prompt from the browser to download the file:
Microsoft Security Bulletin (MS00-058)
- --------------------------------------
Patch Available for "Specialized Header" Vulnerability
Originally posted: August 14, 2000
Summary
=======
Microsoft has released a patch that eliminates a security
vulnerability in Internet Information Server that ships with
Microsoft(r) Windows 2000. Under certain conditions, the
vulnerability could cause a web server to send the source code of
certain types of web files to a visiting user.
Frequently asked questions regarding this vulnerability and the patch
can be found at
http://www.microsoft.com/technet/security/bulletin/fq00-058.asp
Issue
=====
If an IIS server receives a file request that contains a specialized
header as well as one of several particular characters at the end,
the expected ISAPI extension processing may not occur. The result is
that the source code of the file would be sent to the browser.
It is important to note that normal security recommendations militate
strongly against ever including sensitive information in .ASP files
and, if these recommendations have been followed, there would be no
sensitive information to compromise. The specialized header at issue
here cannot be created via a standard Internet browser, so the
request would need to be created by an alternate method.
Affected Software Versions
==========================
- Microsoft Internet Information Server 5.0
Patch Availability
==================
- http://www.microsoft.com/Downloads/Release.asp?ReleaseID=23769
Note: This vulnerability is eliminated by installing Windows 2000
Service Pack 1
http://www.microsoft.com/windows2000/downloads/recommended/sp1/
We recommend that customers apply SP1 as the preferred option for
eliminating this vulnerability, as it has been fully regression
tested and includes fixes for additional issues.
Note: Additional security patches are available at the Microsoft
Download Center
More Information
================
Please see the following references for more information related to
this issue.
- Frequently Asked Questions: Microsoft Security Bulletin MS00-058,
http://www.microsoft.com/technet/security/bulletin/fq00-058.asp
- Microsoft Knowledge Base article Q256888 discusses this issue
and will be available soon.
- Microsoft TechNet Security web site,
http://www.microsoft.com/technet/security/default.asp
- Obtaining Support on this Issue
- This is a fully supported patch. Information on contacting
Microsoft Product Support Services is available at
http://support.microsoft.com/support/contact/default.asp.
Revisions
=========
August 14, 2000: Bulletin Created.
[End of Microsoft Security Bulletin]
Frank Hanny
------------------------------
Date: 21 Aug 2000 21:07:36 GMT
From: abigail@foad.org (Abigail)
Subject: Re: MS IIS and perl syntax errors causing download prompt
Message-Id: <slrn8q36fe.tj3.abigail@alexandra.foad.org>
Frank Hanny (fchanny@lbl.gov) wrote on MMDXLVII September MCMXCIII in
<URL:news:39A18944.44278F6E@lbl.gov>:
-- Regarding the issue I raised previously of certain perl cgi syntax
-- errors resulting in prompt from the browser to download the file:
--
-- Microsoft Security Bulletin (MS00-058)
-- - --------------------------------------
--
-- Patch Available for "Specialized Header" Vulnerability
-- Originally posted: August 14, 2000
There's nothing Perl specific about this, is there?
Abigail
--
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");
------------------------------
Date: Mon, 21 Aug 2000 21:43:00 GMT
From: dufalac@my-deja.com
Subject: Re: Net::Dns broken, gethostbyname OK
Message-Id: <8ns7p1$e41$1@nnrp1.deja.com>
You've probably figured this out, but just in case, I figured I'd put my
2 cents worth in.
1. Go to the <installdir>/blib/lib/Net
2. Edit the DNS.pm file on line 137.
orig :
return defined @mxlist ? @mxlist : ();
new :
return @mxlist ? @mxlist : ()
This resolved my problem on Solaris 2.8 and perl 5.6.0
Later for now :>
-Chris
In article <8nei59$70a$1@nnrp1.deja.com>,
Scott Kirk <undergronk@my-deja.com> wrote:
> Guys,
>
> thanks for the tips. I have tried Michael Fuhr's latest version of
> Net::DNS - but still have the same problem.
>
> From what Michael says on his web pages, it might be worth using an
> older version of Perl (e.g. 5.005). I'll give that a go.
>
> If that doesn't work I know a Unix system admin who might be persuaded
> to look the other way for half-an-hour for a large enough quantity of
> beer.
>
> Cheers
> --
> Scott Kirk
> My deja.com mailbox is full of spam. Use this instead:
> perl -e '$_ = "znvygb: haqretebax\@lnubb.pbz";
> tr/A-Za-z/N-ZA-Mn-za-m/; print;'
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 21 Aug 2000 19:21:28 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Net::SMTP SIZE from EHLO command
Message-Id: <8nrrv8$vo$1@orpheus.gellyfish.com>
On Thu, 17 Aug 2000 21:37:19 GMT nancy wrote:
> I am using Net::SMTP to send a message.
> After sending the EHLO command, I would like to be able to get the SIZE
> value returned by the server, but I'm not sure I can do this.
>
> There are methods to get the domain and banner returned by the server,
> but not one to return the SIZE sent back by the server, as far as I can
> tell.
> Does anyone know of a way to do this?
>
Because Net::SMTP is a subclass of Net::Cmd you can use its method message()
to gain access to the responses of the server - immediately after you have
successfully created the Net::SMTP object $smtp->messages() will return
an array containing the banner and all the ESMTP properties of the server.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: Mon, 21 Aug 2000 21:57:04 +0200
From: "Robert" <robsmiler@bigfoot.com>
Subject: newbie Q: debugging - how to
Message-Id: <39a18948_1@news.arcor-ip.de>
hello,
I'm a bloody beginner with Perl having a quite complex program that syncs
two mysql dbs.
Have programming scills in other languages - but it is *long* ago debugging
on cmd line. As I scanned through dozens of man pages and could not get
into. I am missing examples how to debug foreign code. I know this is most
helpfull, to analyze OPC. So maybe you specialists may help me out to get
in...
Any help will be highly appreciated.
Robert
------------------------------
Date: Mon, 21 Aug 2000 16:22:40 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: newbie Q: debugging - how to
Message-Id: <39A18F90.C8F0CC4B@attglobal.net>
Robert wrote:
>
> hello,
>
> I'm a bloody beginner with Perl having a quite complex program that syncs
> two mysql dbs.
>
> Any help will be highly appreciated.
>
# perldoc perldebug
# perldoc perlrun
------------------------------
Date: Mon, 21 Aug 2000 21:39:28 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: newbie question about "uninitialized variables"
Message-Id: <39a19a64.28263165@news.earthlink.net>
Hi,
I recently found out that I was doing some slightly bad, but not
horrible, juju in my scripts. These are used on CGI, but it's
strictly a Perl question.
I've been declaring my "my" variables at the start of my scripts with
a my($foo1, $foo2); declaration.
The problem I just saw on a script was that, if I never gave the
variables a value, but used them in an if statement condition, I was
getting a "use of unitialized variable" error.
(Some of these were slipping out in the HTML returned in my CGI
scripts in odd places. Otherwise, I would have missed them buried in
the HTML the code spits out at the command line. The worst showed up
on sections with lots of hairy variables I didn't feel like checking
at the commandline.)
I've gotten around this using
$foo1='';
$foo2='';
But, I've got to think there is a better/different/more standard way.
Did I miss a FAQ listing on this one? If so, RTFM's are greatly
appreciated.
Also, other than having -w generate the error (I assume it's -w and
not use strict;), is there any real danger to using uninitialized
variables? (These variables are used as true/false holders, but I
only have code to set them to false (i.e. "no"). If they don't equal
"no" later on, I assume they're "yes"s.)
Thanks,
Jon
------------------------------
Date: 21 Aug 2000 21:54:39 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: newbie question about "uninitialized variables"
Message-Id: <8ns8ev$8s0s3$3@ID-24002.news.cis.dfn.de>
hi,
Jon S. <jonceramic@nospammiesno.earthlink.net> wrote:
> I've been declaring my "my" variables at the start of my scripts with
> a my($foo1, $foo2); declaration.
> The problem I just saw on a script was that, if I never gave the
> variables a value, but used them in an if statement condition, I was
> getting a "use of unitialized variable" error.
well, I guess you are testing something
like
if ($var1 == 23) {dosomething()}
else {...}
you should better use defined() if
you're not sure if the variable's defined or not.
a variable can be
- undefined
- defined, but false (like 0, '', etc.)
- defined and true
so do
if (defined($var) && $var==23) {}
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx
------------------------------
Date: Mon, 21 Aug 2000 19:28:27 GMT
From: jonnydeja@my-deja.com
Subject: Newbie: Help with Fork on NT box
Message-Id: <8nrvs0$4hr$1@nnrp1.deja.com>
I'm having a hard time working with fork. Below is my sample script
where I fork a child process but I'm not getting the results that I
expect.
use strict;
use Time::HiRes qw(usleep);
my $childpid;
my $parentpid;
my $count = 10;
my $num = 0;
$childpid = fork();
while($num < $count)
{
if ($childpid == 0) {
# If $childpid == 0, then we are the child ... Our
# PID is $$, and the parent's pid can be set using:
print "I am the child: $childpid\n";
$num++;
usleep(1000000);
} else {
print "I am the parent\n";
$num++;
usleep(3000000);
}
}
My output is this:
I am the parent
I am the parent
I am the parent
I am the parent
I am the parent
I am the parent
I am the child: 0
I am the child: 0
I am the child: 0
I am the child: 0
I am the child: 0
I am the child: 0
I am the child: 0
I am the child: 0
I am the child: 0
I am the child: 0
I am the parent
I am the parent
I am the parent
I am the parent
What I would expect is the child to print first then either the parent
or child next but this isn't the case. I'm write this script on an NT
4.0 (sp 5) box running ActivePerl 5.6. I'm using "fork" because the
script (to be built upon this example) needs to be portable to and from
Linux and Win NT.
Any help would be much appreciated.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 21 Aug 2000 19:58:44 GMT
From: Dick Latshaw <latsharj@my-deja.com>
Subject: Re: Newbie: Help with Fork on NT box
Message-Id: <8ns1l8$6o8$1@nnrp1.deja.com>
In article <8nrvs0$4hr$1@nnrp1.deja.com>,
jonnydeja@my-deja.com wrote:
> use strict;
> use Time::HiRes qw(usleep);
>
> my $childpid;
> my $parentpid;
> my $count = 10;
> my $num = 0;
>
> $childpid = fork();
>
> while($num < $count)
> {
> if ($childpid == 0) {
> # If $childpid == 0, then we are the child ... Our
> # PID is $$, and the parent's pid can be set using:
>
> print "I am the child: $childpid\n";
> $num++;
> usleep(1000000);
>
> } else {
> print "I am the parent\n";
> $num++;
> usleep(3000000);
> }
> }
>
> My output is this:
>
> I am the parent
> I am the parent
> I am the parent
> I am the parent
> I am the parent
> I am the parent
> I am the child: 0
> I am the child: 0
> I am the child: 0
> I am the child: 0
> I am the child: 0
Turn on autoflush.
$| = 1;
--
Regards,
Dick
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 21 Aug 2000 18:05:45 GMT
From: jonnydeja@my-deja.com
Subject: Re: newline and carriage return problems
Message-Id: <8nrr1a$u8a$1@nnrp1.deja.com>
Have you tried the function call chomp?
In article <8nrns9$q7n$1@nnrp1.deja.com>,
flanagab@hqamc.scott.af.mil wrote:
> I'm trying to do some simple processing of a HTML document's forms.
> All of the data has been passed to a Perl script by the standard POST
> method. I have no problems except with the TEXTAREAs. These can
> contain carriage returns (actually CR LF) within the box.
>
> I'm trying to write the output of the form to a data file in
> tab-delimited form. The trouble is that the LF is being interpreted
as
> a newline. I figured, no problem, I'll strip the \x0A from the
strings
> before I write them to the file, however, when I tried to do this,
they
> would NOT go away!
>
> I tried to split the string and chomp off the newline. It came back.
I
> tried to split the string and chop off the newline, this chopped off
> BOTH the \x0D and \x0A from the string. The trouble here is, I want
to
> KEEP the \cM. I only want to be rid of the \cJ.
>
> I also tried going ahead and chopping off both characters, and then
> reassembling the string, and appending the \x0D characters to each
> section of the string. The string comes back with \x0d \x0a instead.
>
> When I attempt a logical expression to search and replace on the
string,
> it will find the 0A, but it inserts it back in along with my
replacement
> string.
>
> In summation, I can get rid of the \x0a characters, but not without
> getting rid of the \x0d characters as well. No matter what I try, the
> \x0a charaters won't go away. Is there some switch or
> configuration setting to correct this problem? Does anyone have any
> ideas?!
>
> (Would using syswrite help? I haven't tried that yet.)
>
> Thanks in advance for your help!
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 21 Aug 2000 14:17:54 -0400
From: "Eric" <eric.kort@vai.org>
Subject: Re: newline and carriage return problems
Message-Id: <8nrrnc$eh6$1@msunews.cl.msu.edu>
When I had a similar situation, I did a regex replace of \n (newline) with
<br>. This way, the text area data stays in one line in the datafile (the
datafile doesn't see <br> as a new line), but breaks like the original when
you print this data back to the browser (because the browser interprets the
<BR> as a newline, carriage return, as you already know.)
Would that work?
Eric
<flanagab@hqamc.scott.af.mil> wrote in message
news:8nrns9$q7n$1@nnrp1.deja.com...
> I'm trying to do some simple processing of a HTML document's forms.
> All of the data has been passed to a Perl script by the standard POST
> method. I have no problems except with the TEXTAREAs. These can
> contain carriage returns (actually CR LF) within the box.
>
> I'm trying to write the output of the form to a data file in
> tab-delimited form. The trouble is that the LF is being interpreted as
> a newline. I figured, no problem, I'll strip the \x0A from the strings
> before I write them to the file, however, when I tried to do this, they
> would NOT go away!
>
> I tried to split the string and chomp off the newline. It came back. I
> tried to split the string and chop off the newline, this chopped off
> BOTH the \x0D and \x0A from the string. The trouble here is, I want to
> KEEP the \cM. I only want to be rid of the \cJ.
>
> I also tried going ahead and chopping off both characters, and then
> reassembling the string, and appending the \x0D characters to each
> section of the string. The string comes back with \x0d \x0a instead.
>
> When I attempt a logical expression to search and replace on the string,
> it will find the 0A, but it inserts it back in along with my replacement
> string.
>
> In summation, I can get rid of the \x0a characters, but not without
> getting rid of the \x0d characters as well. No matter what I try, the
> \x0a charaters won't go away. Is there some switch or
> configuration setting to correct this problem? Does anyone have any
> ideas?!
>
> (Would using syswrite help? I haven't tried that yet.)
>
> Thanks in advance for your help!
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Mon, 21 Aug 2000 14:59:02 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: newline and carriage return problems
Message-Id: <39A17BF5.EEF84CBD@shentel.net>
I am assuming that you are trying to get the complete output of a text area
to fit on a single field in your flat file database. This is quite easy to
do. If you are goint to be reading this data back into an html page for
later viewing and you wish to preserve the original line breaks you will
have to replace the line returns with <br> tags as follows -
## Remove the line feeds and carriage returns from the description and
replace them with <br>
$cr = chr(13).chr(10);
$Description =~ s/$cr/<br>/g;
If you have no intention of viewing the info with these line returns ever
again use this -
## Remove the line feeds and carriage returns from the description and
replace them with nothing
$cr = chr(13).chr(10);
$Description =~ s/$cr//g;
This will do exactly as you have specified.
Albert Dewey
flanagab@hqamc.scott.af.mil wrote:
> I'm trying to do some simple processing of a HTML document's forms.
> All of the data has been passed to a Perl script by the standard POST
> method. I have no problems except with the TEXTAREAs. These can
> contain carriage returns (actually CR LF) within the box.
>
> I'm trying to write the output of the form to a data file in
> tab-delimited form. The trouble is that the LF is being interpreted as
> a newline. I figured, no problem, I'll strip the \x0A from the strings
> before I write them to the file, however, when I tried to do this, they
> would NOT go away!
>
> I tried to split the string and chomp off the newline. It came back. I
> tried to split the string and chop off the newline, this chopped off
> BOTH the \x0D and \x0A from the string. The trouble here is, I want to
> KEEP the \cM. I only want to be rid of the \cJ.
>
> I also tried going ahead and chopping off both characters, and then
> reassembling the string, and appending the \x0D characters to each
> section of the string. The string comes back with \x0d \x0a instead.
>
> When I attempt a logical expression to search and replace on the string,
> it will find the 0A, but it inserts it back in along with my replacement
> string.
>
> In summation, I can get rid of the \x0a characters, but not without
> getting rid of the \x0d characters as well. No matter what I try, the
> \x0a charaters won't go away. Is there some switch or
> configuration setting to correct this problem? Does anyone have any
> ideas?!
>
> (Would using syswrite help? I haven't tried that yet.)
>
> Thanks in advance for your help!
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Mon, 21 Aug 2000 19:44:08 GMT
From: flanagab@hqamc.scott.af.mil
Subject: Re: newline and carriage return problems
Message-Id: <8ns0q2$5f8$1@nnrp1.deja.com>
Yes, as I mentioned in my message, I did try chomp. The \x0A
(newline) kept coming back. I suspect that the CR is somehow always
being appended to the string for some reason.
In article <8nrr1a$u8a$1@nnrp1.deja.com>,
jonnydeja@my-deja.com wrote:
> Have you tried the function call chomp?
>
> In article <8nrns9$q7n$1@nnrp1.deja.com>,
> flanagab@hqamc.scott.af.mil wrote:
> > I'm trying to do some simple processing of a HTML document's forms.
> > All of the data has been passed to a Perl script by the standard
POST
> > method. I have no problems except with the TEXTAREAs. These can
> > contain carriage returns (actually CR LF) within the box.
> >
> > I'm trying to write the output of the form to a data file in
> > tab-delimited form. The trouble is that the LF is being interpreted
> as
> > a newline. I figured, no problem, I'll strip the \x0A from the
> strings
> > before I write them to the file, however, when I tried to do this,
> they
> > would NOT go away!
> >
> > I tried to split the string and chomp off the newline. It came
back.
> I
> > tried to split the string and chop off the newline, this chopped off
> > BOTH the \x0D and \x0A from the string. The trouble here is, I want
> to
> > KEEP the \cM. I only want to be rid of the \cJ.
> >
> > I also tried going ahead and chopping off both characters, and then
> > reassembling the string, and appending the \x0D characters to each
> > section of the string. The string comes back with \x0d \x0a
instead.
> >
> > When I attempt a logical expression to search and replace on the
> string,
> > it will find the 0A, but it inserts it back in along with my
> replacement
> > string.
> >
> > In summation, I can get rid of the \x0a characters, but not without
> > getting rid of the \x0d characters as well. No matter what I try,
the
> > \x0a charaters won't go away. Is there some switch or
> > configuration setting to correct this problem? Does anyone have any
> > ideas?!
> >
> > (Would using syswrite help? I haven't tried that yet.)
> >
> > Thanks in advance for your help!
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 21 Aug 2000 19:51:08 GMT
From: flanagab@hqamc.scott.af.mil
Subject: Re: newline and carriage return problems
Message-Id: <8ns172$64j$1@nnrp1.deja.com>
Eric:
That's a good idea if all I wanted to do was diplay the data on a web
page. What I'm trying to to though, is to create a data file that is
importable to a standard database software (in this case MS Access).
I'm creating a tab-delimited file. Records will be delimited by the
newline. (Therein lies the problem.) I need to leave the CRs in the
fields, but strip the LFs, since they'll mark the EOR.
I have also tried putting quotation marks around the strings, but the MS
Acces import filter still sees the newline in the middle of the field as
EOR.
Thanks for the input though.
Any other ideas?
In article <8nrrnc$eh6$1@msunews.cl.msu.edu>,
"Eric" <eric.kort@vai.org> wrote:
> When I had a similar situation, I did a regex replace of \n (newline)
with
> <br>. This way, the text area data stays in one line in the datafile
(the
> datafile doesn't see <br> as a new line), but breaks like the original
when
> you print this data back to the browser (because the browser
interprets the
> <BR> as a newline, carriage return, as you already know.)
>
> Would that work?
>
> Eric
>
> <flanagab@hqamc.scott.af.mil> wrote in message
> news:8nrns9$q7n$1@nnrp1.deja.com...
> > I'm trying to do some simple processing of a HTML document's forms.
> > All of the data has been passed to a Perl script by the standard
POST
> > method. I have no problems except with the TEXTAREAs. These can
> > contain carriage returns (actually CR LF) within the box.
> >
> > I'm trying to write the output of the form to a data file in
> > tab-delimited form. The trouble is that the LF is being interpreted
as
> > a newline. I figured, no problem, I'll strip the \x0A from the
strings
> > before I write them to the file, however, when I tried to do this,
they
> > would NOT go away!
> >
> > I tried to split the string and chomp off the newline. It came
back. I
> > tried to split the string and chop off the newline, this chopped off
> > BOTH the \x0D and \x0A from the string. The trouble here is, I want
to
> > KEEP the \cM. I only want to be rid of the \cJ.
> >
> > I also tried going ahead and chopping off both characters, and then
> > reassembling the string, and appending the \x0D characters to each
> > section of the string. The string comes back with \x0d \x0a
instead.
> >
> > When I attempt a logical expression to search and replace on the
string,
> > it will find the 0A, but it inserts it back in along with my
replacement
> > string.
> >
> > In summation, I can get rid of the \x0a characters, but not without
> > getting rid of the \x0d characters as well. No matter what I try,
the
> > \x0a charaters won't go away. Is there some switch or
> > configuration setting to correct this problem? Does anyone have any
> > ideas?!
> >
> > (Would using syswrite help? I haven't tried that yet.)
> >
> > Thanks in advance for your help!
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 21 Aug 2000 19:58:48 GMT
From: flanagab@hqamc.scott.af.mil
Subject: Re: newline and carriage return problems
Message-Id: <8ns1lb$6o9$1@nnrp1.deja.com>
I am trying to get the complete output of the TEXTAREA in a field of my
database, however, I need to *retain* the CRs in the field. The problem
is that Perl keeps trying to translate the CRs into CRLFs. The LF is
not acceptable, since this is interpreted as EOR.
The <BR> idea would work if all I wanted to do was display the data on
the web, but that's not the purpose. Do you have any other ideas?
In article <39A17BF5.EEF84CBD@shentel.net>,
Albert Dewey <timewarp@shentel.net> wrote:
> I am assuming that you are trying to get the complete output of a text
area
> to fit on a single field in your flat file database. This is quite
easy to
> do. If you are goint to be reading this data back into an html page
for
> later viewing and you wish to preserve the original line breaks you
will
> have to replace the line returns with <br> tags as follows -
>
> ## Remove the line feeds and carriage returns from the description
and
> replace them with <br>
> $cr = chr(13).chr(10);
> $Description =~ s/$cr/<br>/g;
>
> If you have no intention of viewing the info with these line returns
ever
> again use this -
>
> ## Remove the line feeds and carriage returns from the description
and
> replace them with nothing
> $cr = chr(13).chr(10);
> $Description =~ s/$cr//g;
>
> This will do exactly as you have specified.
>
> Albert Dewey
>
> flanagab@hqamc.scott.af.mil wrote:
>
> > I'm trying to do some simple processing of a HTML document's forms.
> > All of the data has been passed to a Perl script by the standard
POST
> > method. I have no problems except with the TEXTAREAs. These can
> > contain carriage returns (actually CR LF) within the box.
> >
> > I'm trying to write the output of the form to a data file in
> > tab-delimited form. The trouble is that the LF is being interpreted
as
> > a newline. I figured, no problem, I'll strip the \x0A from the
strings
> > before I write them to the file, however, when I tried to do this,
they
> > would NOT go away!
> >
> > I tried to split the string and chomp off the newline. It came
back. I
> > tried to split the string and chop off the newline, this chopped off
> > BOTH the \x0D and \x0A from the string. The trouble here is, I want
to
> > KEEP the \cM. I only want to be rid of the \cJ.
> >
> > I also tried going ahead and chopping off both characters, and then
> > reassembling the string, and appending the \x0D characters to each
> > section of the string. The string comes back with \x0d \x0a
instead.
> >
> > When I attempt a logical expression to search and replace on the
string,
> > it will find the 0A, but it inserts it back in along with my
replacement
> > string.
> >
> > In summation, I can get rid of the \x0a characters, but not without
> > getting rid of the \x0d characters as well. No matter what I try,
the
> > \x0a charaters won't go away. Is there some switch or
> > configuration setting to correct this problem? Does anyone have any
> > ideas?!
> >
> > (Would using syswrite help? I haven't tried that yet.)
> >
> > Thanks in advance for your help!
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 21 Aug 2000 17:57:19 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: newline and carriage return problems
Message-Id: <39A1A5BF.A4B0D20F@shentel.net>
I am not sure which chr( ) item is which but try one of these two -
$cr = chr(13);
$Description =~ s/$cr//g;
or
$cr = chr(10);
$Description =~ s/$cr//g;
I have always used these in pairs and never took the time to remember which
one was which. One or the other of the two codes above might do what you
want. Try them out and see if you don't get the results you are looking for.
Albert Dewey
flanagab@hqamc.scott.af.mil wrote:
> I am trying to get the complete output of the TEXTAREA in a field of my
> database, however, I need to *retain* the CRs in the field. The problem
> is that Perl keeps trying to translate the CRs into CRLFs. The LF is
> not acceptable, since this is interpreted as EOR.
>
> The <BR> idea would work if all I wanted to do was display the data on
> the web, but that's not the purpose. Do you have any other ideas?
------------------------------
Date: Mon, 21 Aug 2000 15:33:07 -0400
From: "David Mears" <davem@skantech.net>
Subject: Re: opening several files with the same file handle
Message-Id: <39a1840d.0@news.skantech.net>
FYI: cheep fix, must learn to read FAQ more completely.
> @allentries = <DATABASE>;
that was bad... an completely unnecessary.
removed it, replaced for FOREACH with a while(<DATABASE>) and not rid of a
bogus readline and all was better. Did 8 million +/- lines in under 5
minutes.
an earlier version had
while(<DATABASE>)
{
readline $_;
do stuff...
}
which caused a memory leak and confused me. I guess I need more practice
with perl. Just for completeness, I'll implement the suggestions you made
and be a bit more considerate with my source in the future. ;)
David Mears
<nobull@mail.com> wrote in message news:u91yziczr2.fsf@wcl-l.bham.ac.uk...
> "David Mears" <davem@skantech.net> writes:
>
> > There seams to be a memory leak which I can't find associated with the
way
> > I'm doing it. The first two files it processes in seconds.
>
>
> > here's the source that I think is important.
>
> Please make sure before you post. Top-and-tail the source you think
> it important so that it actually runs, then check that it really does
> reproduce the problem then post this actual source to the group.
>
> Before you do that it's probably a good idea to fix all the things
> that are wrong with the code and will distract us from seeing your
> real problem.
>
> > foreach $t_item (@items)
>
> I think your cut-and-paste has gone mad. This belongs below.
>
> You've missed out my. In general the loop control variable in a for
> statement should always be prefixed my.
>
> > opendir (searchdir, $Root);
>
> You've missed out the "or die" clause.
>
> > @thedirs = readdir(searchdir);
>
> You've missed out my.
>
> > closedir(searchdir);
> > @sorta = sort {Decode_Month($b) <=> Decode_Month($a)} @thedirs;
>
> You should consider a Swartzian-transform.
>
> > foreach $thedir (@sorta)
>
> You've missed out my.
>
> > {
> > if (($thedir ne ".") and ($thedir ne ".."))
> > {
> > $newroot = $Root . "/" . $thedir;
>
> This is more simply written as:
> $newroot = "$Root/$thedir";
>
> > opendir (search2, $newroot);
>
> You've missed out the "or die" clause.
>
> > @thedir2 = readdir(search2);
>
> You've missed out my.
>
> > closedir(search2);
>
> > @sorteddir = sort {substr($a,8) <=> substr($b,8)} @thedir2;
>
> You should consider a Swartzian-transform.
>
> > foreach $the2 (@sorteddir)
>
> You've missed out my.
>
> > {
> > if ($the2 =~ "^VPRAcct.")
>
> This is better written as:
> if ($the2 =~ /^VPRAcct./ )
>
> > {
> > $items[$nn_x] = $newroot . "/" . $the2;
> > $nn_x = $nn_x + 1;
> > }
>
> This is better done as:
> push @items, "$newroot/$the2"
>
> > }
> > }
> > }
>
> In fact the whole preceding section is better written as
>
> push @items, map { "$newroot/$_" } grep { /^VPRAcct./ } readdir(search2);
>
> This is where the foreach at the start should be.
>
> > {
> > print "\nOpening ",$t_item,"\n";
> > # $t_item = $items[x_cnt];
> > $t_item = "<" . $t_item;
> > open (DATABASE,$t_item) or die "Can't Open Radius Log.";
>
> Bare in mind that $t_item is an alais for an entry in @items. You
> probably don't want to be munging @items. You should also report the
> error. So make that:
>
> open (DATABASE,"<$t_item") or die "Can't Open Radius Log $t_item: $!";
>
>
> > &processentrys;
> > close (DATABASE);
> > }
> >
> >
> > sub processentrys
> > {
> > print "Loading...";
> > @allentries = <DATABASE>;
>
> You've missed out my.
>
> > print "Done, ",$#allentries + 1," lines.\n";
>
> This is more conventionally written as:
>
> print "Done, ",scalar(@allentries)," lines.\n";
>
> > $n_line = 0;
> > foreach $_ (@allentries)
>
> The whole point of $_ is that it is the default variable. If you are
> going to explicitly name the variable don't use $_. If you want to
> use $_ don't name it.
>
> > {
> > process stuff....
>
> You memory leak is probably in there.
>
> > }
> > }
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4085
**************************************