[8723] in Perl-Users-Digest
Perl-Users Digest, Issue: 2340 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 16 17:07:40 1998
Date: Thu, 16 Apr 98 14:00:25 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 16 Apr 1998 Volume: 8 Number: 2340
Today's topics:
Re: .= so why not =. ? (John Klassa)
Re: .= so why not =. ? <bmb@ginger.libs.uga.edu>
Re: array of matches in s/// (Jim Turner)
Re: Bill Gates should be invited to O'Reilly's "Free So <ucntcme@cyberhighway.net>
Re: Bill Gates should be invited to O'Reilly's "Free So <ben@hayamasa.demon.co.uk>
Re: Bill Gates should be invited to O'Reilly's "Free So <ucntcme@cyberhighway.net>
Re: Bill Gates should be invited to O'Reilly's "Free So <ucntcme@cyberhighway.net>
can't get sub swrite from perlform to work :( Matthew.Wickline@usa.net
Carriage return/line feed in text files (Chris & Sheila King)
Re: Carriage return/line feed in text files <dtbaker_@flash.net>
Re: Carriage return/line feed in text files <bmb@ginger.libs.uga.edu>
CLPM CONTENT POLICE (was info on cookies) <andrewf@cp.pathfinder.com>
Re: commenting a whole block? <lr@hpl.hp.com>
Determining If Date Falls Within a Range <rxruck2@uswest.com>
Re: File IO Question: opening for appending without flo <lr@hpl.hp.com>
Re: Info Regarding Perl 5.005 (Stuart McDow)
Re: Memory Leak? Embedding into C <fox@vulpes.com>
Problems running perl from html under NT--2nd try <broadstockt@saic.com>
Problems running perl from html under NT <tbroadstock@acm.org>
Re: Recursive Calls in Perl ? <andrewf@cp.pathfinder.com>
Solaris Perl install: I am NOT using GNU as(1)!!!!!! Chris_Schoenfeld@sonic.net
Re: using perl scripts from C++ <andrewf@cp.pathfinder.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Apr 1998 19:49:17 GMT
From: klassa@aursgh.aur.alcatel.com (John Klassa)
Subject: Re: .= so why not =. ?
Message-Id: <6h5nbt$l75$1@aurwww.aur.alcatel.com>
On Thu, 16 Apr 1998 14:51:51 -0400,
Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
->Okay, following is not a perl question, but most FAQ's and books I've
->read make use of the 'foobar' expression. Considering what this stands
->for, is anyone else out there slightly tired of seeing it, as am I?
->Chances are good that if I routinely used profane variable names in my
->posts, someone would call me on it.
I think the version you're thinking of is FUBAR... The variables
"foo" and "bar" (and even "baz") are canonical. When you need a
variable and aren't interested in its name, it's "foo"...
--
John Klassa / Alcatel Telecom / Raleigh, NC, USA <><
------------------------------
Date: Thu, 16 Apr 1998 16:16:06 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: .= so why not =. ?
Message-Id: <Pine.A41.3.96.980416161046.63622G-100000@ginger.libs.uga.edu>
(I sent this to Bob directly before I realized his note was an echo, so
I thought I'd repeat it here ... )
Hi,
Yeah, I sort of thought that to be the case. Unfortunately, now that
FUBAR is part of my memory bank (which it wasn't until I asked a
programmer a decade ago what the heck 'foobar' was about), the ubiquitous
'foo's and 'bar's out there keep bouncing on that button. Probably I need
therapy :-)
Thanks for your note,
Brad
On Thu, 16 Apr 1998, Bob Trieger wrote:
> You call that a rant?
> Source: The Free On-line Dictionary of Computing (27Dec97) [foldoc]
> http://www.dictionary.com
> foobar
> Another common {metasyntactic variable}; see {foo}. Hackers
> do *not* generally use this to mean {FUBAR} in either the
> slang or jargon sense.
> --
> Bob Trieger | Titanic: big boat, bigger
> sowmaster@juicepigs.com | iceberg, big deal
------------------------------
Date: 16 Apr 1998 19:57:53 GMT
From: turnerj@cliffy.lmtas.lmco.com (Jim Turner)
Subject: Re: array of matches in s///
Message-Id: <6h5ns2$bjh1@quest.lmtas.lmco.com>
Bart Lateur (bart.mediamind@tornado.be) wrote:
: Ronald J Kimball wrote:
:
: >You seem to have already disqualified all the possible solutions to your
: >problem.
:
: Which brings me to the kernel of my gripe. I can get an array of matches
: in m//:
:
: @match = /$pattern/;
:
: but not in s///. I sincerely miss it. The translation scheme was really
: just an example of how it could be useful.
:
: So I'd like to propose an extension to Perl, in the form of a special
: variable array. In agreement with the $& variable, which contains the
: whole matched string, @& could be a decent name.
:
: I'm pretty sure that internally, Perl builds this array of matches. It
: surely does in m//. Only, in s/// you can't reach into it except via $1
: etc.
:
: Usage:
:
: s/$key/&interpolate($translate{$key},@&)/e;
:
: That surely would solve my problem in a very neat way, wouldn't you
: think?
:
: Bart.
Have you considered the "e" modifier for s/// ? This allows the
right side to be like a small Perl Program, which gets evaluated for each
match, ie
@v = ();
$s = 'foo is as foo does';
$s =~ s/(foo)/push (@v,$1); 'bar'/eg;
This sets @v to ('foo','foo').
Hope this helps!
Jim Turner
------------------------------
Date: Thu, 16 Apr 1998 13:56:15 -0600
From: Bill Anderson <ucntcme@cyberhighway.net>
Subject: Re: Bill Gates should be invited to O'Reilly's "Free Software Summit" (was Re: RMS should be invited to O'Reilly's "Free Software Summit")
Message-Id: <3536625F.3B60B7CD@cyberhighway.net>
Ben Bullock wrote:
>
> Nathan V. Patwardhan wrote:
> >
> > Ben Bullock (ben@hayamasa.demon.co.uk) wrote:
> >
> > : I don't have exact data as to how many copies of the books they
> > : sell this way, but you don't have any real sales figures to back up
> > : your opinion either, so I don't see this discussion getting
> > : anywhere.
> >
> > But then again, you brought the X-Windows books up. Since you don't
> > have any evidence to backup your claims, you shouldn't have ever
> > mentioned such a topic.
>
> I do have evidence, but I don't have inconclusive proof, that
> the X windows books are a major part of O'Reilly's business.
>
If you have evidence, and lack _inconclusive_ proof, you must have _conclusive_
proof. Then, by all means, demonstrate it.
> I don't see why anyone would regard this as a topic worth debating.
>
> Perhaps some people disagree with my opinions about free software
> and its documentation, but can't think of a good rebuttal, so they
> decide to quibble about things like this.
>
> --
> Ben Bullock
Then your argument fails, for I have not seen any of your 'opinions' about
OpenSource Software and the documentation of it. If *you* don't see a topic
worth discussing/debating then stay out and let others do what *they* see fit
to do.
--
Bill Anderson Cyberhighway Internet Services, SYCON
"Pluralitas non est ponenda sine neccesitate."
Plurality should not be assumed without neccesity.
------------------------------
Date: Thu, 16 Apr 1998 21:27:25 +0100
From: Ben Bullock <ben@hayamasa.demon.co.uk>
Subject: Re: Bill Gates should be invited to O'Reilly's "Free Software Summit" (was Re: RMS should be invited to O'Reilly's "Free Software Summit")
Message-Id: <353669AD.5E5E684E@hayamasa.demon.co.uk>
Bill Anderson wrote:
> If you have evidence, and lack _inconclusive_ proof, you must have _conclusive_
> proof. Then, by all means, demonstrate it.
Bill, I posted a correction to this statement about ten minutes
after the original post, so there is not much excuse for your
attack here.
> Then your argument fails, for I have not seen any of your 'opinions' about
> OpenSource Software and the documentation of it. If *you* don't see a topic
> worth discussing/debating then stay out and let others do what *they* see fit
> to do.
I can't understand how you can have missed my opinions on this
thread. :-).
Would you like a summary? Or could you look at dejanews.
Incidentally I wrote something about the `open source'
controversy which is at
http://www.hayamasa.demon.co.uk/open-source.html
I hope there are lots of trivial inaccuracies in there that
will keep the flames burning for another 40 or so posts but
if not please let me know so that I can add some.
--
Ben Bullock
------------------------------
Date: Thu, 16 Apr 1998 14:34:38 -0600
From: Bill Anderson <ucntcme@cyberhighway.net>
Subject: Re: Bill Gates should be invited to O'Reilly's "Free Software Summit" (was Re: RMS should be invited to O'Reilly's "Free Software Summit")
Message-Id: <35366B5E.884C38B5@cyberhighway.net>
Ben Bullock wrote:
>
> Donovan Rebbechi wrote:
>
> > I think that our disagreement ultimately boils down to the question of
> > whether you believe that companies have a valid role to play in backing
> > free software
>
> No, you are completely wrong in your assumption about what I think.
>
There was no assumption about what you think made in the above quoted remark.
> --
> Ben Bullock
--
Bill Anderson Cyberhighway Internet Services, SYCON
"Pluralitas non est ponenda sine neccesitate."
Plurality should not be assumed without neccesity.
------------------------------
Date: Thu, 16 Apr 1998 14:32:06 -0600
From: Bill Anderson <ucntcme@cyberhighway.net>
Subject: Re: Bill Gates should be invited to O'Reilly's "Free Software Summit" (was Re: RMS should be invited to O'Reilly's "Free Software Summit")
Message-Id: <35366AC6.F32997A7@cyberhighway.net>
Chris Nandor wrote:
>
> In article <3533712E.ADECDA5E@mindspring.com>, keithmur@mindspring.com wrote:
>
> # Chris Nandor wrote:
> # > Apologies, but I rarely consider it useful to consider something as true
> # > that which is not.
> # >
> # I'd be willing to bet that you do it every day. Do you ever refer to
> # "the sun rising"? Does it really? A "blue sky"? Tell me, where is
> # this blue that is inherent in the sky?
>
> Well, I would argue that thise are true, based on our senses.
How about 'My car won't start' *It* does not start, you start it. ;)
"Actions speak louder than words" ... you figure it out ;)
I oculd easily argue that these, being relative, are no more or less true than
the statement that Information (as opposed to mere information) possesses Will
and Intelligence. Blue is a term we have place upon a certain frequency of
light. It also is a term denoting emotional state. It is possible, likely
probable, that the spectrum of color 'blue' is not called 'blue' by all
intelligent beings. Pure Truth could not be relative in such a matter. The sun
does not rise, as a person or yeast might, but, like all the points that have
been opposing your statements share, abstraction is important to the way we
think of things.
>
> # Y'know, Chris, ultimately it's all simplifying fictions.
>
> You make a very good point. I have no problem with saying something that
> is not true for simplicity's sake so long as we all know it is not true.
> But in this case, many people think that information actually does will
> and act.
>
Perhaps it does possess intelligence. Perhaps it is a *result* of intelligence,
denoting an inherent will. I wonder if your statement about '...we all know...'
will lead us into an epistimology discussion .... ;) Someone may 'know' it is
true.
> # (I think talking about software "wanting to be free" is at least
> # defensible as such a simplifying fiction, but may not work for some).
>
> I agree. I am just guarding against the notions that information in
> actuality desires something, or does something, anything, at all.
>
But why? What does it matter if someone believes it? It begins to delve into
religion if you go that far. You have gone beyond guarding your thoughts to
trying to 'convert' others' thoughts.
> Thanks for your post. Who knows, perhaps Information does possess intelligence?
It seems to me that this particular thread could have been shortened if you
would have posted the above several posts back. I am unsure of your actual
intentions, but you came off as someone who is insistent that your way is The
Only Truth (tm) regarding Things-We-Don't-Know-Yet (also tm ;).
>
> --
> Chris Nandor mailto:pudge@pobox.com http://pudge.net/
> %PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
> #== New Book: MacPerl: Power and Ease ==#
> #== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==#
--
Bill Anderson Cyberhighway Internet Services, SYCON
"Pluralitas non est ponenda sine neccesitate."
Plurality should not be assumed without neccesity.
------------------------------
Date: Thu, 16 Apr 1998 15:38:32 -0600
From: Matthew.Wickline@usa.net
Subject: can't get sub swrite from perlform to work :(
Message-Id: <6h5q89$80k$1@nnrp1.dejanews.com>
was looking for something like swrite
found swrite in the perlform page (horray)
attepted to run it, no luck. :(
The file I'm using is
======================
#!/usr/bin/perl -w
use Carp;
sub swrite {
croak "usage: swrite PICTURE ARGS" unless @_;
my $format = shift;
$^A = "";
formline( $format, @_ );
return $^A;
}
$string = swrite(<<'END', 1, 2, 3);
Check me out
@<<< @||| @>>>
END
print $string;
=======================
(w/o the ===== of course)
perl -wc works just fine on it
my only output is "Segmentation fault" and a core dump
if I comment out the formline line, then it will quitely do nothing.
What might I be missing?
-matt
PS
perl -version is
This is perl, version 5.003 with EMBED
built under solaris at Jan 31 1997 17:32:06
+ suidperl security patch
Copyright 1987-1996, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Thu, 16 Apr 1998 20:05:17 GMT
From: cking@wenet.net (Chris & Sheila King)
Subject: Carriage return/line feed in text files
Message-Id: <35366381.8100097@news.wenet.net>
Ok, I'm the newest of newbies. Sitting here with a tutorial book.
I just installed Perl5 on my Win95 machine, but expect to also put it on
my Linux Box shortly. Portability issues are important.
Anyhoo...
I'm doing the practice text exercises, like saving the following to a
the file hello.pl:
print 'Hello, World!';
And then I go to the command line and type
perl hello.pl
It works fine. But, if I try to create any text files with more than one
line, I can't. I can't figure it out. I just get one big long line
(until eventually my DOS display wraps it).
How do I create a LineFeed/Carriage Return in Perl for:
1. Win32
and
2. if it's different...Unix/Linux systems.
Thanks,
Sheila King
cking@wenet.net
------------------------------
Date: Thu, 16 Apr 1998 14:30:00 -0600
From: Dan Baker <dtbaker_@flash.net>
Subject: Re: Carriage return/line feed in text files
Message-Id: <35366A48.2281@flash.net>
I'm pretty new too, so if I go astray, I'm sure someone will correct me.
;)
Chris & Sheila King wrote:
>
> Ok, I'm the newest of newbies. Sitting here with a tutorial book.
...snip
> It works fine. But, if I try to create any text files with more than one
> line, I can't. I can't figure it out. I just get one big long line
> (until eventually my DOS display wraps it).
---------
I would guess you are forgetting to add the \n at the end of each line
you are printing... unless you TELL perl to add a newline, it won't...
By the same token, when reading IN text, you almost always have to use
the chomp($string) function to remove the newline from the end.
>
> How do I create a LineFeed/Carriage Return in Perl for:
> 1. Win32
> and
> 2. if it's different...Unix/Linux systems.
----------
shouldn't make a difference as long as you use the chomp() function to
remove because it "knows" whether the host OS uses just a newline
character, or LF/CR, or whatever.
Dan
------------------------------
Date: Thu, 16 Apr 1998 16:53:43 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Carriage return/line feed in text files
Message-Id: <Pine.A41.3.96.980416165111.63622I-100000@ginger.libs.uga.edu>
Just a quick warning:
print 'Hello, World\n'; ### won't do what you want, instead:
print "Hello, World\n"; ### \n needs the double quotes
Brad Baxter
UGA
On Thu, 16 Apr 1998, Dan Baker wrote:
> I would guess you are forgetting to add the \n at the end of each line
> you are printing... unless you TELL perl to add a newline, it won't...
> By the same token, when reading IN text, you almost always have to use
> the chomp($string) function to remove the newline from the end.
> Dan
------------------------------
Date: Thu, 16 Apr 1998 16:15:02 -0400
From: "Andrew F. Lee" <andrewf@cp.pathfinder.com>
Subject: CLPM CONTENT POLICE (was info on cookies)
Message-Id: <Pine.GSO.3.95.980416155516.18074G-100000@cp.pathfinder.com>
Abigail, et al:
In my humble opinion, Perl and CGI are commmon companions. I think that
CGI questions coming from a Perl programmer ought to be welcome on
comp.lang.perl.misc (misc being short for miscellaneous, from the Latin
miscellus -- mixed).
As a Perl programmer, I do not usually come to clpm questions about syntax
so much as questions about semantics. Apologies to those who are studying
Perl in a vacuum with no intention of ever writing applications.
My point: If you have something useful to say, please do. If you have
just had too much caffeine, please refrain from posting pointless and
sniveling comments (unless they are funny).
</FLAMAGE>
On 14 Apr 1998, Abigail wrote:
> Gilles Chong (glchy@csah.com) wrote on MDCLXXXVII September MCMXCIII in
> <URL: news:35332C56.7433130D@csah.com>:
> ++ Hi,
> ++ im playing with cookies for the moment. Generating them with a
> ++ javascript is very simple. But im stuck when it comes to getting the
> ++ cookie and reading it in Perl. It seems that there is NOT an env
> ++ variable which corresponds to the cookie.
>
> Then that's a problem you have to take up with your server, not with Perl.
>
>
>
> Abigail
> --
> perl -pwle '$_ .= reverse'
>
>
-------------------------------------------------------------
Andrew F. Lee | |
Software Engineer | parenttime.com |
email: andrewf@pathfinder.com | 1271 Avenue of the Americas |
Phone: (212) 522-2769 | New York, N.Y. 10020 |
-------------------------------------------------------------
When I say, "Ignore the man behind the curtain."
That is because there is no man behind the curtain.
------------------------------
Date: Thu, 16 Apr 1998 12:57:20 -0700
From: Larry Rosler <lr@hpl.hp.com>
To: Jason Christian <jason@primal.ucdavis.edu>
Subject: Re: commenting a whole block?
Message-Id: <353662A0.8CC95A67@hpl.hp.com>
Jason,
Thanks for an enlightening response to a question that I have wondered
about for a while (and resorted to inserting a # at the beginning of
each line -- sigh; at least, they don't have to be syntactically correct
that way). I guess another way to do it might be to embed the code in
"if (0) {" and "}". Which leads to the following observation:
Though it is certainly off-topic here, I hope C programmers will not be
led astray by Ji Huang's statement about commenting out a block of code
in C by bracketing it with "/*" and "*/". This is NOT the best way to
do it (unless you never put comments in your own code!). Comments do
not nest! The best way is to use the preprocessor: bracket the code
with "#if 0" and "#endif".
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
Jason Christian wrote:
>
> On Thu, 16 Apr 1998, Ji Huang wrote:
>
> > Hi:
> >
> > I am a new user of perl and maybe i am not well informed but I really
> > think it's extremely inconveniece in perl for me to bar a whole block of
> > codes from executing.
> >
> > In C or C++ or Java all you have to do is put
> >
> > /*
> >
> > block
> >
> > */
> >
> > , but in perl i have to put # sign at the beginning of each line of the
> > block.
> >
> > Is there any easier way for me to do it?
>
> I sometimes do this:
>
> sub IGNORETHIS{
> #lines of perlcode here.
> }
>
> Of course it doesn't really ignore it, it compiles it, complains if its
> wrong, and no doubt this is a really flagrant waste of expensive
> computer memory... but *if* the lines are legal, and *if* memory is cheap,
> it does seem to work. I am not proposing this as an answer to the
> question, just noting that from an economist's perspective (with cheap
> memory and expensive programmer time) it is acceptable. If from more
> sensible perspectives (e.g., that of a certified if not certifiable perly
> king or queen) this is a crime against humanity, good taste, and the
> commons, I hope I will be so advised. Thank you.
>
> ---------------------------------------------------------------------------
> Jason Christian University of California, Davis
> jason@primal.ucdavis.edu Agricultural and Resource Economics
> Office:(530)752-1357 FAX:(530)752-5614 Davis, CA 95616
------------------------------
Date: Thu, 16 Apr 1998 15:09:32 -0500
From: Ryan Rucker <rxruck2@uswest.com>
Subject: Determining If Date Falls Within a Range
Message-Id: <3536657C.85624605@uswest.com>
Hello,
I have this bit of code that I'm using to determine if a given
date string (in the form "19980415", for example) falls within
a range of dates (note: $testdate would normally be extracted
from a line in a file, not hardcoded).
***********************************************************
use Date::Manip;
# set up variable for previous business day
$bday_str = &DateCalc("today","- 1 business days",\$err);
$today = &UnixDate("today","%a");
$testdate = "19980415";
if ($today eq "Mon") {
$begin_str = &DateCalc("today","- 3 days",\$err);
$begin_bday = substr($begin_str, 0, 8);
$end_bday = substr($bday_str, 0, 8);
} else {
$begin_bday = substr($bday_str, 0, 8);
$end_bday = $begin_bday;
}
if ($testdate <= $end_bday) {
if ($testdate >= $begin_bday) {
print ("\$testdate is <= \$end_bday\n",
"AND >= \$begin_day\n");
} else {
print ("\$testdate is NOT <= \$end_bday\n",
"or >= \$begin_bday\n\n");
}
} else {
print ("\$testdate is NOT <= \$end_bday\n",
"or >= \$begin_bday\n\n");
}
**************************************************************
>From my simple tests (changing $testdate to various dates),
this appears to work, but I was just wondering what a more
graceful way to do this might be.
Is there a way to specify a date range in Perl? In layperson's
lingo, instead of doing:
if ($testdate <= $end_bday) {
if ($testdate >= $begin_bday) {
.
.
I'd like to do:
if ($testdate *within* $begin_bday *and* $end_bday) {
Or even:
if ($testdate *between* $begin_bday *and* $end_bday) {
I've looked in the FAQ, under the date and number portions, and
flipped through "Learning Perl", but didn't see what I'm looking
for. Also, I suppose I could do the whole comparison with Date
Manip, but as I'm new to Perl, I was just wondering if there's
another way that I'm not aware of.
Thanks,
Ryan
------------------------------
Date: Thu, 16 Apr 1998 13:28:46 -0700
From: Larry Rosler <lr@hpl.hp.com>
To: Marshall Dudley <mdudley@execonn.com>
Subject: Re: File IO Question: opening for appending without flock?
Message-Id: <353669FE.D29DAA61@hpl.hp.com>
Marshall Dudley wrote:
>
> Larry Rosler <lr@hpl.hp.com> wrote:
>
> > It is not necessary to lock a file being appended to. The flock
> > documentation is too conservative on this point; a better example would
> > show a file being opened for read/write (+<...).
> >
> > The following description comes from my HP-UX manual fopen(3S), but the
> > underlying behavior is guaranteed by the open(2) function in all ANSI-C
> > compliant implementations:
> >
> > When a file is opened for append ... it is impossible to overwrite
> > information already in the file. All output is written at the end of
> > the file, regardless of intervening calls to fseek(). If two separate
> > processes open the same file for append, each process can write freely
> > to the file without fear of destroying output being written by the
> > other. Output from the two processes will be intermixed in the file in
> > the order in which it is written.
> >
> > Larry Rosler
> > Hewlett-Packard Laboratories
> > lr@hpl.hp.com
> >
>
> Following this type of advise I found elsewhere I removed all the locks
> from my appends several months ago. Since then I spent countless hours
> in the last month tracking down lost infromation, and I just now
> confirmed that if you do not lock a file on an append, you can and under
> certain circumstance absolutely will, lose any imformation you attempt
> to append.
>
> The following code proved to me that the append will corrupt and lose
> information if you do not lock an append:
>
> unless ($dup) {
> open (BANNER,
> ">>/home2/domains/netxotica/cgi-bin/mag-email.txt")
> print BANNER " $email ;";
> close (BANNER);
> open (BANNER,
> ">>/home2/domains/netxotica/cgi-bin/mag-email.txt2")
> print BANNER "$email\n";
> close (BANNER);
> }
>
> In this case, I found that all the missing entries in the .txt file,
> were getting still recorded in the .txt2 file. In all I found that
> between 10% and 15% of all entries were getting thrown away in the .txt
> file, which gets opened locked, and rewritten by another process. If a
> append is attemped during the lock by another other process, the lock is
> ignored, and the data is lost or corrupted.
>
> Beware. All the information that says that you do not need to lock an
> append operation is wrong. It can lead to serious data loss and
> corruption. I know from experience! Now I have to go back and add the
> all the locks back that I pulled out earlier. :<
>
> Marshall
We are discussing quite different things. The documentation I quoted
says clearly, "If two separate processes open the same file for append,
...". In the case you are describing, the other process has opened and
locked the file for *rewriting*, not appending. So you must cooperate
by testing the lock before appending. Unless you do, the operating
system will seek to the instantaneous end-of-file and append your data,
which the other process will then proceed to overwrite on its next write
because its file pointer has not moved as a result of your append.
The only other comment on my submission opined that "incomplete" records
(i.e., records not terminated with new-line characters) could appear in
the middle of other records. Of course this is so -- just visualize two
binary appends to a file. What is a "record" then? But when
line-buffering is enabled (as it is by default for "text" files), and
complete lines are appended, the integrity of each record (line) is
guaranteed.
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 16 Apr 1998 20:03:57 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: Info Regarding Perl 5.005
Message-Id: <6h5o7d$e7f$1@ns1.arlut.utexas.edu>
mbeattie@sable.ox.ac.uk (Malcolm Beattie) writes:
>
> >Unix users have already had threads for three decades now, though --
> > It's called "fork".
>
> Yeah, but it doesn't really work doing
>
> exit({value => 42, name => "Smith", callback => sub { foo() }});
>
> when you try to return a value from a separate process ;-)
What about having had the child drop that "exit value" into a shared
memory segment (or a shared mmap()ed memory object) right before it
exited? The parent, catching the SIGCHLD, would know to go get the
"exit value".
Ouch. Didn't see the 'callback => sub { foo() }' part. That would be
difficult to do. At least not without eval(). Hmm, let me think about
it... You might be right.
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
"It is obvious that about 750,000 people ago, Austin was a wonderful City."
------------------------------
Date: Thu, 16 Apr 1998 15:58:42 -0400
From: Ken Fox <fox@vulpes.com>
Subject: Re: Memory Leak? Embedding into C
Message-Id: <353662F2.3C0D@vulpes.com>
Scott wrote:
> Well, the problem is that I'm using a mult-tasking interpreted environment
> that is built around a real time database.
You have to be really careful if you have multiple active interpreters.
It's been a while since I played with this stuff, but you'll need to set
MULTIPLICITY when you build perl. I can't remember if the resulting
perl
is binary compatible with all your existing perl modules either -- be
careful and read the docs.
> The command interpreters (known as doprocs) do die when they aren't used for
> a while, and I could set up a single command interpreter to handle perl, and
> use inter-process communication (message queues and so forth), but I'd rather
> just call a script from inside the process and keep things simple(r).
I'm not sure why you need to resort to a single process and IPC just to
share
an interpreter in a single process. All I suggested is that instead of
starting
multiple interpreters in a process, just start one and reuse it. You're
not
threading are you? That will cause all sorts of trouble in 5.004. I'd
start
one perl interpreter in a single thread and then mutex lock access to
it.
Kind of heavy handed, but at least it's safe...
> I would just think that a Perl_destruct would undo anything a Perl_construct
> would do, just as a common sense matter. It sounds like Perl has a problem.
Everything has design limitations. ;) You might want to consider that
creating
a new interpreter is quite expensive. If you've already done it once in
your
process, why do it again? Take a look at mod_perl for an excellent
example of
embedding perl. You might be able to get some insight on how to embed
it more
effectively within your own application.
BTW, you don't want to use 5.004_65 in a production application. That's
the
development track and can be very unstable. At the very least, it's
going to
change faster than you can possibly keep track of. ;) Until 5.005 (or a
new
production release of 5.004), you'll just have to work around any perl
bugs.
- Ken
------------------------------
Date: Thu, 16 Apr 1998 16:16:49 -0400
From: Tom Broadstock <broadstockt@saic.com>
Subject: Problems running perl from html under NT--2nd try
Message-Id: <35366731.21127B16@saic.com>
I am having problems using the submit button on a html form to call a
perl script and generate a new html page. How is this done in the NT
environment using IIS 4.0? Perl will run from the command line but I
need it to run from the browser. Sample html and perl code
demonstrating a simple example that uses a form and submit would be
appreciated.
I'm trying to avoid using the ASP. Actually, I'm really trying to port
perl code that was developed in a UNIX environment to the NT--forms and
scripts.
Thanks.
Tom Broadstock
------------------------------
Date: Thu, 16 Apr 1998 16:11:38 -0400
From: Tom Broadstock <tbroadstock@acm.org>
Subject: Problems running perl from html under NT
Message-Id: <353665FA.9265706D@saic.com>
I am having problems using the submit button on a html form to call a
perl script and generate a new html page. How is this done in the NT
environment using IIS 4.0? Perl will run from the command line, but I
need it to run from the browser. Sample html and perl code
demonstrating a simple example that uses a form and submit would be
appreciated.
I'm trying to avoid using the ASP. Actually, I'm really trying to port
perl code that was developed in a UNIX environment to the NT - forms and
scripts.
Thanks.
Tom Broadstock
------------------------------
Date: Thu, 16 Apr 1998 15:48:46 -0400
From: "Andrew F. Lee" <andrewf@cp.pathfinder.com>
Subject: Re: Recursive Calls in Perl ?
Message-Id: <Pine.GSO.3.95.980416153853.18074E-100000@cp.pathfinder.com>
On 14 Apr 1998, Jonathan Feinberg wrote:
> Grace Cheng <gcheng@corp.sgi.com> writes:
>
> > The manul says the "Subroutines may be called recursively"
> > but I couldn't seem to get it to work.
>
> Grace - if you post a short code example that doesn't work the way you
> think it should, we'll be more able to help you. In the meantime,
> please read the "perlsub" document that comes with perl. I'm guessing
> that you're having trouble with parameter passing and scoping. Here's
> a recursive subroutine that does work.
>
> sub fact ($) {
> my $n = shift;
> return 1 if $n < 2;
> return $n * fact($n - 1);
> }
>
> --
I missed the original post :(
My (related) question is: Does Perl do tail recursion? (And what the
heck is tail recursion anyway?)
The following is an example from "Effective Perl Programming" by Joseph
Hall and Randal Schwartz: (Buy it! Read it! Carry it close!)
#!/usr/local/bin/perl
sub count_recurse {
local *DIRH;
my ($file_count_ref, $dir_count_ref, $dir_name) = @_;
$$dir_count_ref++; # count cwd
opendir DIRH, $dir_name or die "Couldn't open $dir_name: $!";
my @dir = readdir DIRH;
close (DIRH);
for $file (@dir) {
next if ($file eq '.' or $file eq '..');
if (-f "$dir_name/$file") {
$$file_count_ref++; # reference count goes up
next;
}
next if -l "$dir_name/$file"; # skip symlinks
next unless -d "$dir_name/$file"; # if it's a dir, we recurse
count_recurse($file_count_ref, $dir_count_ref, "$dir_name/$file");
}
}
$file_count = $dir_count = 0;
&count_recurse (\$file_count, \$dir_count, ".");
print "$file_count files\n$dir_count directories\n";
This script dies with the error, "Couldn't open directory_foo: to many
open filehandles" on this here machine (when doing a LOT of files and
subdirs). That has to be a false error message!
Any thoughts?
-------------------------------------------------------------
Andrew F. Lee | |
Software Engineer | parenttime.com |
email: andrewf@pathfinder.com | 1271 Avenue of the Americas |
Phone: (212) 522-2769 | New York, N.Y. 10020 |
-------------------------------------------------------------
When I say, "Ignore the man behind the curtain."
That is because there is no man behind the curtain.
------------------------------
Date: Thu, 16 Apr 1998 15:20:18 -0600
From: Chris_Schoenfeld@sonic.net
Subject: Solaris Perl install: I am NOT using GNU as(1)!!!!!!
Message-Id: <6h5p68$6jo$1@nnrp1.dejanews.com>
I am trying desperately to build Perl5.004_04 on s Sparc Solaris 2.5.1 box.
I have done this a zillion times on other Sparcs (OK, about 12 times).
Anyways...
Configure insists that I am using GNU as(1) but I am not.
I have tried:
1. Putting /usr/ccs/bin in front of my PATH.
2. Setting GCC_EXEC_PREFIX=/usr/ccs/bin
3. FTPing the as and ld from other boxes, and putting their location in front
of my PATH.
4. Invoking Configure with sh Configure -Dcc='/usr/local/bin/gcc -
B/usr/ccs/bin/'
Still, Configure gives me the warnings.
I have never experienced this before on this platform.
Any help or ideas would be appreciated.
BTW When I try _03, I do not get the warning, but it says that my GCC
compiler is not working. I have compiled test.c with /usr/local/bin/gcc
successfully.
Thanks
Chris
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Thu, 16 Apr 1998 15:51:51 -0400
From: "Andrew F. Lee" <andrewf@cp.pathfinder.com>
Subject: Re: using perl scripts from C++
Message-Id: <Pine.GSO.3.95.980416154958.18074F-100000@cp.pathfinder.com>
On Tue, 14 Apr 1998, Michael Badt wrote:
> Does anyone know where I can get information, or sample programs for
> calling perl scripts from code writtem in C++, and what setups do I
> have to make in my C++ project for activating it ?
>
> Thanks,
>
Suggested reading "Advanced Perl Programming" by Srinam Srinivasan
(O'Reilly)
-------------------------------------------------------------
Andrew F. Lee | |
Software Engineer | parenttime.com |
email: andrewf@pathfinder.com | 1271 Avenue of the Americas |
Phone: (212) 522-2769 | New York, N.Y. 10020 |
-------------------------------------------------------------
When I say, "Ignore the man behind the curtain."
That is because there is no man behind the curtain.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 2340
**************************************