[13952] in Perl-Users-Digest
Perl-Users Digest, Issue: 1362 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 12 14:05:37 1999
Date: Fri, 12 Nov 1999 11:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <942433512-v9-i1362@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 12 Nov 1999 Volume: 9 Number: 1362
Today's topics:
cgi page instead of html <news@gallacci.com>
Re: cgi page instead of html <flavell@mail.cern.ch>
CPAN with LWP (Danny Aldham)
Errors installing IO Module (Danny Aldham)
Re: function: full(\*FILEHANDLE) (Neko)
Re: Generating pi (Craig Berry)
Help With CyberCash.... (Mr. X)
Re: How can I determine different "use" statements? <david.kernen@bms.com>
Re: how to create a random id? (Eric Bohlman)
Re: how to create a random id? (Craig Berry)
Re: mSQL <russellm@bellsouth.net>
Re: Parse delimited file with \n's. <gkl200@my-deja.com>
Re: Perl Extensions. Arrgh. <dan@tuatha.sidhe.org>
Re: Perl Parsing teknik2000@my-deja.com
Re: printing a number with 3 digits <kurumi@3di.org>
Re: regular expression to parse html out- <removethis_vod@writemail.com>
Re: Removing occurrences of a string from another strin <AgitatorsBand@yahoo.com>
Re: Senior Software Engineer (Perl)-Positions Available <emschwar@rmi.net>
Re: Senior Software Engineer (Perl)-Positions Available <emschwar@rmi.net>
Serious memory leak in MacPERL? (Tom Sheppard)
Re: sorting withing multiple files (Eric Bohlman)
Re: split (Craig Berry)
Too much Perl? (Steve Linberg)
Re: Trying to combine a cgi perl script <latsharj@my-deja.com>
Re: URGENT!!!!!!!!!!!!!! <newsposter@cthulhu.demon.nl>
Win32::Process problem <mruedy@alidian.com>
Writing data to file on another server. <cans1@hotmail.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 12 Nov 1999 17:42:24 +0100
From: "Dott Gabriele Gallacci" <news@gallacci.com>
Subject: cgi page instead of html
Message-Id: <80hg27$j02$1@nslave2.tin.it>
Hello,
I need to substitute html page with my cgi generated one (with perl): how
can I do that?
Can I configure apache to start perl script when .html page are requested?
I cannot use embedded perl.
Thx
Gabriele Gallacci
gabriele@gallacci.com
------------------------------
Date: Fri, 12 Nov 1999 19:27:04 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: cgi page instead of html
Message-Id: <Pine.HPP.3.95a.991112191307.23951F-100000@hpplus01.cern.ch>
On Fri, 12 Nov 1999, Dott Gabriele Gallacci wrote:
> I need to substitute html page with my cgi generated one (with perl): how
> can I do that?
Exactly the same way you'd do it with a CGI-generated one written
in COBOL or FORTRAN, or any other language that you could think of.
(It's been a while since I wrote anything in BCPL...).
> Can I configure apache to start perl script when .html page are requested?
^^^^^^^^^^^^^^^^
You evidently already know where to look. If you couldn't see it
yourself from the Apache documentation, then good places on usenet to
ask are comp.infosystems.www.servers.(unix|ms-windows) depending on your
OS. For either set of OSes, the answer would be yes.
For the modern way to do it, look at AddHandler. But the old way using
magic mime types also works. Put your directive(s) inside a <Files...>
or <FilesMatch...> bracket specifying the particular .html files that
you want treated in this way. If this is unix, don't forget to make
them world executable as well as readable (mode 0??5), and of course
Options +ExecCGI must be in effect for the directory.
I would offer more advice, but this is the wrong place, and I sense
that the referee's whistle is about to be blown... if not a red card...
------------------------------
Date: 12 Nov 1999 18:53:50 GMT
From: danny@hendrix.postino.com (Danny Aldham)
Subject: CPAN with LWP
Message-Id: <80hnnu$5vh$1@hendrix.postino.com>
X-Newsreader: TIN [version 1.2 PL2]
Reading the man pages for CPAN, it looks like it will not work through
a proxy that requires authentication. Is there any way to plug the
LWP module into CPAN to get around this problem?
--
Danny Aldham Providing Certified Internetworking Solutions to Business
www.postino.com E-Mail, Web Servers, Mail Lists, Web Databases, SQL & Perl
------------------------------
Date: 12 Nov 1999 18:13:35 GMT
From: danny@hendrix.postino.com (Danny Aldham)
Subject: Errors installing IO Module
Message-Id: <80hlcf$4se$1@hendrix.postino.com>
X-Newsreader: TIN [version 1.2 PL2]
I am trying to install the IO module onto a RH Linux6.0 machine,
with perl5.005_03 . When I run make I get the output below:
[root@project IO-1.19]# make
cc -c -Dbool=char -DHAS_BOOL -O2 -DVERSION=\"1.19\" -DXS_VERSION=\"1.19\" -fpic -I/usr/local/lib/perl5/5.00503/i586-linux/CORE -DI_POLL IO.c
IO.xs:72: warning: static declaration for `Perl_newCONSTSUB' follows non-static
IO.xs: In function `Perl_newCONSTSUB':
IO.xs:79: `hints' undeclared (first use in this function)
IO.xs:79: (Each undeclared identifier is reported only once
IO.xs:79: for each function it appears in.)
IO.xs:83: `copline' undeclared (first use in this function)
make: *** [IO.o] Error
Any help appreciated.
--
Danny Aldham Providing Certified Internetworking Solutions to Business
www.postino.com E-Mail, Web Servers, Mail Lists, Web Databases, SQL & Perl
------------------------------
Date: Fri, 12 Nov 1999 09:48:23 -0800
From: tgy@chocobo.org (Neko)
Subject: Re: function: full(\*FILEHANDLE)
Message-Id: <GKErOLgxF1Bd7IGjvwC0wEBFnw6K@4ax.com>
On Thu, 11 Nov 1999 22:32:34 -0500, Jeff Pinyan <jeffp@crusoe.net> wrote:
>Below is a function that returns the closest full line to your current
>position in a file. As a side-effect, it does change your position in the
>file.
I prefer this function call to that of the subject line:
full FILEHANDLE; # let the prototype do its job
>sub full (*) {
> local *FH = shift;
> return scalar <FH> if tell(FH) == 0;
> seek FH, -length($/), 1;
What if a line isn't a line? What if it's a paragraph ($/ = "") or a record ($/
= \1234) or the entire file ($/ = undef)?
> <FH>;
> return if eof(FH);
Is test for eof() necessary? The next line will return undef for end of file.
> return scalar <FH>;
>}
>
>If this function is in someway broken, please let me know. It will be
>included in an article on PerlMonth about using files and filehandles.
The following function accounts for the different meanings of $/. It is
untested and may or may not work.
sub full (*) {
my $fh = shift;
my $mark = tell $fh;
return scalar <$fh> unless $mark;
if (not defined $/) {
seek $fh, 0, 2;
} elsif ($/ eq "") {
seek $fh, -4, 1; # length("\n\n") <= 4
<$fh> until tell $fh >= $mark;
} elsif (ref $/ eq 'SCALAR') {
my $size = ${$/} + 0;
if ($size) {
seek $fh, $size - $mark % $size, 1;
} else {
# $/ = \0 currently works like $/ = ""
seek $fh, -4, 1;
<$fh> until tell $fh >= $mark;
}
} else {
seek $fh, -(length $/), 1;
<$fh>
}
scalar <$fh>;
}
Hmm... maybe I should error check all those seeks.
More untested code. Shorter and doesn't rely on knowing the different guises of
$/; unfortunately, it will chug through all the previous 'lines' of which there
will undoubtedly be many.
sub full (*) {
my $fh = shift;
my $mark = tell $fh;
seek $fh, 0, 0;
<$fh> until tell $fh >= $mark;
scalar <$fh>;
}
--
Neko | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=
------------------------------
Date: Fri, 12 Nov 1999 18:11:02 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Generating pi
Message-Id: <s2om1m7jhsq18@corp.supernews.com>
Larry Rosler (lr@hpl.hp.com) wrote:
: A way that gets the job done *fast* if all you want is double precision:
:
: $pi = 4 * atan2(1, 1);
:
: But *everybody* knows that! No fun at all. :-(
Yeah, to me this is morally equivalent to
$pi = 3.141592654 # ...and so forth out to double precision limit
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "They do not preach that their God will rouse them
a little before the nuts work loose." - Kipling
------------------------------
Date: Fri, 12 Nov 1999 18:46:50 GMT
From: xavier10@die.spammers.hotmail.com (Mr. X)
Subject: Help With CyberCash....
Message-Id: <382c5a6f.102501068@news.cois.on.ca>
Hi all
This has been dumped in my lap this morning....not happy....
The company I work for just recently setup CyberCash on their secure
servers. It works just great, it verify the credit cards and all. BUT
it does not mail the merchant a verification or indication that there
has been a CC sale. The company wants the script to email the merchant
the information that CyberCash gets back from the bank. I have talked
extensively with CyberCash about this and they indicate it is not
their policy to help with stuff like this. I have modified the script
to mail the merchant, but I cannot find out how to include the
information in the email.
I hope someone has had experience with this, as we are going nuts here
trying to figure it out!
The merchant des not want to use a shopping cart script as he has no
need for it....
Any help would be appreciated!
THX.
Brandon.
Please email me here (as this is the acct I check regularly)
fstop@cois.on.ca
------------------------------
Date: Fri, 12 Nov 1999 13:52:06 -0500
From: David Kernen <david.kernen@bms.com>
Subject: Re: How can I determine different "use" statements?
Message-Id: <382C61D6.1EC66E14@bms.com>
Your problem requires that you use require instead of using use.
Eg:
if(condition){
require 'module1.pm';
require 'module2.pm';
}else{
require 'module3.pm';
require 'module4.pm';
}
Of course there are implications when using require instead of use.
First, require doesn't like double colons, and it won't assume the .pm.
So if your module has '::' in it you need to replace it with the
separator character (i.e. a forward slash). And of course you'll need
to include the ".pm" part of the module name regardless.
Also, use automatically will run the module's import method if it has or
inherits one. require will not, so you will have to manually run import
if you need to. Or else just be aware that nothing from the module's
namespace has been imported into the caller's namespace, which is
usually no big deal.
And finally, require happens at run time, not at compile time (which is
the whole point). This means that you will need to identify the modules
subroutines as subroutines and not treat them as functions. In other
words, you can
do &module1::sub1 or module1::sub1() or even a &module1::sub1() but not
a plain old module1::sub1.
Hope this helps...
Dave Kernen
mozo wrote:
> Since the use statements are run on compile-time,
> How can I determine which module to be used in program?
> I do it this way:
>
> if(condition){
> use module1;
> use module2;
> }else{
> use module3;
> use moudle4;
> }
> ...
> ...
>
> But It seem need to have all 4 modules availble all the time,
> no matter what the condition is.
> What can I do?
>
> --
> J±R½å ºôªê°ê»Ú http://wahoo.com.tw
> mailto:mozo@wahoo.com.tw
------------------------------
Date: 12 Nov 1999 17:32:42 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: how to create a random id?
Message-Id: <80hivq$bh5$2@nntp8.atl.mindspring.net>
Tom Briles (sariq@texas.net) wrote:
: Abigail wrote:
: >
: > $id = '=' x 17;
:
: If there's one thing I've learned in the time I've been reading
: Abigail's posts, it's that she's obsessed with the number 17.
:
: Fess up, Abigail! What's the significance? IQ / 10? The age at which
: you first (fill in the blank)ed?
:
: Enquiring minds want to know!
If you multiply it by 1000, divide it by the answer to the Ultimate
Question of Life, The Universe, and Everything, and truncate the result
to an integer, you get the HTTP status code for 'not found.'
------------------------------
Date: Fri, 12 Nov 1999 18:37:32 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: how to create a random id?
Message-Id: <s2onjctlhsq32@corp.supernews.com>
Fabian Rahm (fabian@linda.ch) wrote:
: I want to generate in perl a random id like e3479b76955is5349
: How can I make it?
The problem is insufficiently specified. In essence, there are two
subproblems:
(1) Generation of 'random' strings.
(2) Determination that candidate strings have not been used previously.
The former can be handled using an infinite variety of algorithms built
around rand() to choose random numbers or characters or the like, which
are then concatenated or interpolated together to form a candidate string.
The latter involves maintaining a list of strings currently in use; this
may be a hash or an external database of some kind. You may need to
consider race conditions (another process/thread grabs a string in between
checking for its prior use and recording its new use).
Best of luck!
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "They do not preach that their God will rouse them
a little before the nuts work loose." - Kipling
------------------------------
Date: Fri, 12 Nov 1999 12:44:11 -0600
From: Mark Russell <russellm@bellsouth.net>
Subject: Re: mSQL
Message-Id: <382C5FFA.635DCE62@bellsouth.net>
MySQL & mSQL, Yarger, et al (OReilly)
Erick Jensen wrote:
> Does anyone know of a good reference (web site, book, etc.) for accessing an
> mSQL database with Perl?
------------------------------
Date: Fri, 12 Nov 1999 17:01:27 GMT
From: gkl200 <gkl200@my-deja.com>
Subject: Re: Parse delimited file with \n's.
Message-Id: <80hh54$vdm$1@nnrp1.deja.com>
I tried Text::CSV_XS the first time with no success also,
but what you got below worked fine. Thanks for your post!
In article <80f9ds$sonr$1@fu-berlin.de>,
"Samuel Kilchenmann" <skilchen@swissonline.ch> wrote:
> gkl200 <gkl200@my-deja.com> wrote in message
> news:80esu6$20n$1@nnrp1.deja.com...
> In any case: just ignore the recommendations to use split() for this
> task (its just a waste of time). You may kindly request the guys who
> recommend the use of split to show you a working solution for your
> problem.
>
> Take a look at modules like Text::CSV_XS or DBD::CSV. They are much
> more appropriate for this kind of task.
>
> Here (again) one of my usage examples of Text::CSV_XS (btw. it also
> shows that K. Bandes - in another thread - is wrong, when he claims,
> that this module is unable to handle multiline fields. But the other
> comments he made about the coverage of the CSV story in the FAQ are
> mostly correct.):
>
> #!/wherever/perl -w
> use strict;
> use Text::CSV_XS;
>
> my $csv = Text::CSV_XS->new({ binary => 1, sep_char => "\t" });
>
> my $buffer = "";
> my $success = undef;
> my $rec_count = 0;
>
> while(<DATA>) {
> $buffer .= $_;
> $success = $csv->parse($buffer);
> if ($success) {
> display_record(++$rec_count, $csv->fields());
> $buffer = "";
> }
> }
> if (not $success) {
> my $err = $csv->error_input();
> print "parse CSV failed at:\n", $err, "\n";
> }
>
> sub display_record {
> my $rec_count = shift;
> my @fields = @_;
> my $field_count = 0;
>
> print "Record: $rec_count [\n";
> foreach my $field (@fields) {
> print "Field: ", ++$field_count, " = ", $field, "\n";
> }
> print "] $rec_count\n";
> }
>
> __DATA__
> "AAA" "BBB" "CCC
> DDD
> EEE
> FFF"
> "AAA" "B""B""B" "C CC
> DDD
> EEE
> FFF"
> a b c
>
> This prints:
> Record: 1 [
> Field: 1 = AAA
> Field: 2 = BBB
> Field: 3 = CCC
> DDD
> EEE
> FFF
> ] 1
> Record: 2 [
> Field: 1 = AAA
> Field: 2 = B"B"B
> Field: 3 = C CC
> DDD
> EEE
> FFF
> ] 2
> Record: 3 [
> Field: 1 = a
> Field: 2 = b
> Field: 3 = c
> ] 3
>
> (I am sorry to have used <Tabs> in this posting. I know that <Tabs>
> are inappropriate on usenet, because of their nonportability.)
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 12 Nov 1999 17:35:00 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Perl Extensions. Arrgh.
Message-Id: <8dYW3.3151$c06.28546@news.rdc1.ct.home.com>
Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
> [A complimentary Cc of this posting was sent to Dan Sugalski
> <dan@tuatha.sidhe.org>],
> who wrote in article <bDAW3.2983$c06.25659@news.rdc1.ct.home.com>:
>> > My question was about the result of conversion to C.
>>
>> The return's an SV. *All* returns from an XS module are ultimately SVs.
> Then I understand your initial remark as advocating
> SV *
> foo()
> CODE:
> RETVAL = 5;
> OUTPUT:
> RETVAL
> as working?
Then you misunderstand. I'm advocating adding an OUTPUT: RETVAL section to
clear up the compiler errors the original poster was seeing with RETVAL
being undefined. The fact that the return value was bogus was beside the
point.
Making xsubpp smart enough to do automagic conversion to an SV would be a
clever thing indeed, and probably really useful for the truly lazy, but
I'm not sure that the effort'd be worth it.
Dan
------------------------------
Date: Fri, 12 Nov 1999 17:11:55 GMT
From: teknik2000@my-deja.com
Subject: Re: Perl Parsing
Message-Id: <80hhom$vt2$1@nnrp1.deja.com>
I tried to delete the duplicate but no luck. Very tired when i posted
the message, thus the duplicates and spelling probs:)
In article <MPG.129528c1a73f1d9798a1e5@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
> In article <80fr0r$p53$1@nnrp1.deja.com> on Fri, 12 Nov 1999 01:37:31
> GMT, teknik2000@my-deja.com <teknik2000@my-deja.com> says...
>
> Does Deja.com let one cancel an article after it has been posted? If
> so, you should have canceled one of your two posts. This one has
> 'Parsing' spelled correctly.
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 12 Nov 1999 09:59:31 -0800
From: kurumi <kurumi@3di.org>
Subject: Re: printing a number with 3 digits
Message-Id: <382C5583.A7E80124@3di.org>
"G.Ananth Somayaji" wrote:
>
> Hi,
> I am trying to print a number so that it should always
> have only 3 digits. For example 7 should be printed as 007. Looks
> sort of a simple task but the solution has evaded me for a couple
> of days now.
>
> Thanks in advance
> Ananth
Ouch. Were those billable hours?
2 days x 8 hours x US $200/hour / 1 LOC = US $3200/LOC [0]
I want that gig
[0] currency conversions left to the reader
--
kurumi
Roadgeek WWTBAM quiz: http://www.kurumi.com/cgi-bin/wwtbam.pl
------------------------------
Date: Sat, 13 Nov 1999 00:07:48 +0530
From: vod <removethis_vod@writemail.com>
Subject: Re: regular expression to parse html out-
Message-Id: <382C5E7C.D2E30C10@writemail.com>
Thanks a lot i wil check out the perldoc.
U see i had just learnt Perl and wasnt aware of "perldoc".
V0D
David Cassell wrote:
> vod wrote:
> >
> > Hello,
> >
> > Before u say anything, i want to say that
> > i know it may not be wise but never the less i am trying to make a
> > small search script for my web-site. I want the script to search
> > thru the .htm* pages but only the text that is outside the html tags,
> > i.e. that is outside < > tags.
>
> Okay, I won't say it. I'll be thinking it, though. :-)
> Seriously, if this is *your* website and you control what
> is in the HTML, then you can be sure that many of the
> bad things which break a common regex won't occur. Otherwise,
> you'll need to use a parser to solve this problem.
>
> > At the moment i have the script ready that searches all the page
> > blindly what i was hoping to make a regular expression that could
> > eliminate html tags < >.
> > Basically i think the reg ex has to look for any word starting
> > with "<" followed by anything and ending with ">".
>
> Sort of. Go to a command prompt and type this:
>
> perldoc -q html.+string
>
> [that's a regex in there: it searches for any FAQ with the
> letters html, followed by something, followed by 'string' -
> and perldoc makes the search case-insensitive for you]
>
> You'll find:
> [1] the simple-minded regex solution you wanted;
> [2] a more sophisticated regex solution which handles
> HTML tags that go over more than one line, or have
> quoted angle-brackets, or HTML comments;
> [3] a ref to TomC's striphtml program;
> [4] examples of why regexes won't work in general; and
> [5] a ref to HTML::Parse, which is but one of several
> ways to parse HTML in Perl.
>
> HTML::Parser is another way. So is Parse::RecDescent .
>
> > I am not very good at reg exes so i was hoping to find a
> > a reg exes from anyone of u guys/girls that would do the needfull
> > i.e. elimiate html tags in a .html page.
>
> Always check the FAQ first. It's surprising how often the
> answer is already there, waiting for you.
>
> David
> --
> David Cassell, OAO cassell@mail.cor.epa.gov
> Senior computing specialist
> mathematical statistician
------------------------------
Date: Fri, 12 Nov 1999 17:40:20 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: Removing occurrences of a string from another string
Message-Id: <8iYW3.530$wJ6.100469@news.shore.net>
Abigail <abigail@delanet.com> wrote:
: Really? You have looked through the manpages and FAQs of Perl, and
: you managed to miss to s///?
: That's utterly amazing. What's next, someone reading a book about
: Java, and "missing" how to do OO?
What's even more amazing is that two people actually pointed him to the
correct documentation and gave him some useful help before you felt the
need to belittle him like this.
Boy, Abigail sure is smart. I wish I were more like Abigail.
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: 12 Nov 1999 10:18:27 -0700
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Senior Software Engineer (Perl)-Positions Available
Message-Id: <xkfyac36330.fsf@valdemar.col.hp.com>
mgjv@comdyn.com.au (Martien Verbruggen) writes:
> On 11 Nov 1999 14:27:31 -0700,
> Eric The Read <emschwar@rmi.net> wrote:
> > "David Winsen" <david@hotjobs2000.com> writes:
> > > Senior Software Engineer (Perl)-Positions Available
>
> > > URGENT MESSAGE!
> >
> > To you, maybe. The vast majority of us could care less.
>
> No, actually, I couldn't :)
Look, alt.usage.english is just down the road over thataway, if you wanna
be literal about idiom. :)
Besides, I *could* care less. Really. It's just that I can't be
bothered to.
-=Eric
--
"Cutting the space budget really restores my faith in humanity. It
eliminates dreams, goals, and ideals and lets us get straight to the
business of hate, debauchery, and self-annihilation."
-- Johnny Hart
------------------------------
Date: 12 Nov 1999 10:21:21 -0700
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Senior Software Engineer (Perl)-Positions Available
Message-Id: <xkfvh7762y6.fsf@valdemar.col.hp.com>
tadmc@metronet.com (Tad McClellan) writes:
> If it is not truly urgent, then you are a liar, and are
> subject to ignoration (or worse).
^^^^^^^^^^
I just have to ask-- is that a word in your normal lexicon? 'cause it
just *SCREAMS* PHB-speak to me.
BOFH: "Let's just ignore him."
PHB: "Let's subject him to ignoration."
-=Eric
--
"Cutting the space budget really restores my faith in humanity. It
eliminates dreams, goals, and ideals and lets us get straight to the
business of hate, debauchery, and self-annihilation."
-- Johnny Hart
------------------------------
Date: Fri, 12 Nov 1999 17:39:38 GMT
From: sheppard@magma.ca (Tom Sheppard)
Subject: Serious memory leak in MacPERL?
Message-Id: <sheppard-1211991239380001@192.168.0.1>
Greetings,
I guess I'm pushing the limits of MacPERL for my particular application,
but it does seem to have a memory leak which aggravates the problem.
What I've noticed is that if I create a very large hash that, firstly, it
seems to consume an inordinate amount of memory and second, I can't get it
freed up requiring me to quit the program and relaunch. I've allocated 72
MB to MacPERL, which is all it will use even if given more, and I'm still
running out of memory.
Here's what I'm doing. I'm massaging massive text files of the Internet
Movie Database for import to FileMaker Pro where I collate the data. The
IMDb folks don't publish key to title or name mapping so I need to create
these keys myself. The amount of data is very large. Over 185,000 movie
titles and over 1.3 million actor/movie pairs.
I use the hashing ability in PERL to assign a unique numeric key to the
movie title or actor name and then, whenever I want to lookup the key for
some other information, such as country, rating, director, etc. I use the
hash function to do that rapidly.
$titles{ $newTitle } = ++$key;
where $newTitle is a variable length text string containing the movie
title. Once I have all the titles loaded I can then replace the long title
names with short title keys such as:
$countryKey = $titles{ $countryTitle };
where $countryTitle is the title of the movie which I want to replace with
the numeric key in the mapping of titles and their countries.
That all works well, but I need to handle a lot of data from many
different files. I repeatedly call a function which may build a hash and
then I explicitly free it before returning by doing an:
undef %someHash;
This seems to help a little but not all the memory is recovered. If I
repeatedly call the function I eventually run out of memory requiring me
to quit MacPERL and relaunch it.
Sometimes I can manage to run one script through to completion, close it,
and then I try to run another script. But the memory has not all been
recovered, even though the first script has terminated and been closed,
such that the next script runs out of memory even though it's not trying
to do too much.
Since MacPERL hasn't been updated in a long time I guess I'm looking for a
more elegant workaround to ensure all memory is properly freed. Is there a
more memory efficient way to allocate and reliably free hashes?
Thanks,
...Tom
------------------------------
Date: 12 Nov 1999 17:26:05 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: sorting withing multiple files
Message-Id: <80hijd$bh5$1@nntp8.atl.mindspring.net>
Tad McClellan (tadmc@metronet.com) wrote:
: On Thu, 11 Nov 1999 16:37:37 -0800, Makarand Kulkarni
: <makkulka@cisco.com> wrote:
: > my ( undef, undef, $ip_address ) = spit ( ',', $_); # read third
: ^^^^
:
: Undefined subroutine &main::spit called at ...
Common sense says that any language whose mascot is a camel is going to
have a built-in spit() function...
------------------------------
Date: Fri, 12 Nov 1999 18:32:26 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: split
Message-Id: <s2on9qfehsq19@corp.supernews.com>
Nigell Boulton (nigell.boulton@rade.net) wrote:
: How do I open a text file that has data such as
:
: fred:30
: bill:25
: john:30
:
: open the file and then change and display it on screen in the format
:
: Fred is 30 years old
: Bill is 25 years old
: John is 30 years old
perl -nwe 'printf "%s is %d years old\n", (split /:/);'
: thanks for your help
You're welcome. And best of luck explaining to your professor how it
works. :)
: reply by email to nigell@nigell.com
Ask here, get answer here.
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "They do not preach that their God will rouse them
a little before the nuts work loose." - Kipling
------------------------------
Date: Fri, 12 Nov 1999 14:04:50 -0500
From: slinberg@crocker.com (Steve Linberg)
Subject: Too much Perl?
Message-Id: <slinberg-1211991404500001@bsg-ma2d-179.ix.netcom.com>
<three-quarter-serious>
So after about 15 years of sweating it out in C, early 6502 assembler, and
a handful of other languages I dabbled in but never really mastered more
than necessary to get a job done, I stumbled on Perl 4 or 5 years ago. I
used it to write a text preprocessor for maintaining web sites (which I
still use in a more generic fashion -- insanely useful). My early Perl
looked like (bad) C, but over the years I've refined my style more and
more, studying the experts and falling ever more deeply in love with this
wonderful language.
My comfort with Perl idioms has coincided with the lowest rate of bugs in
code that I've ever experienced. Startling percentages of what I write
now run perfectly on the first try, something I never achieved in C or
assembler, although my knowledge of those languages was pretty thorough.
Some of it is undoubtedly experience after 20 years now (yikes) of pushing
bits around, but I really credit Perl with freeing me up to express ideas
and concepts in lovely ways that other rigid languages can't handle.
The problem is that now writing C is like pulling teeth. Perl has ruined
me for all other languages. I've written Perl almost exclusively for
about three years now, rewriting Unix utilities, maintenance scripts for
databases, big web applications, bulletin boards, and so forth. I've
grown to rely on hashes, dynamic data structures, regular expressions, and
garbage collection so heavily that going back to C feels like switching
from my nice toolbox stuffed with Craftsman goodies to stone and flint.
I still feel, though, that I need to get back to doing more C. C is the
mother tongue, after all, and I feel I'm being disloyal to the mother.
Perl is doing too much work for me, managing all my variables and memory,
giving me English-like constructs to manipulate text and language with.
It's gotten too easy. I've forgotten how to write a complete application
with an interface. In a way, I fear I'm losing my edge as a
once-hard-core, close-to-the-iron programmer. Perl lets me do wonderful
things, but I feel I'm a little too removed from the metal. I don't want
to wake up a script kiddie one day.
Just wondering if any other Perl hackers experience this sensation. Maybe
it's the uptight blueblood Yankee in me, feeling that I'm not suffering
enough and that I need more penance, that I've got it too easy. :) Maybe
people in Californina don't experience this. I wonder.
</three-quarter-serious>
--
Steve Linberg
Chief Goblin
Silicon Goblin Technologies
------------------------------
Date: Fri, 12 Nov 1999 17:19:09 GMT
From: Dick Latshaw <latsharj@my-deja.com>
Subject: Re: Trying to combine a cgi perl script
Message-Id: <80hi67$9e$1@nnrp1.deja.com>
In article <382C3B58.4422A69E@syntes.com>,
Syntes <words@syntes.com> wrote:
> I'm working on combining two cgi perl scripts. They are for form data
> and uploading files. I have searched for a script for what I need and
> have been having problems combining them. Any insight to my problem
> would be greatly appreciated. I do have a script for a form. I also
> have a script for uploading. I need both to work together for the same
> web page.
Your question was just answered in the thread entitled 'GURU HELP NEEDED
FOR NEWBIE'. Go to deja.com and search for messages with 'HELP' in the
title.
--
Regards,
Dick
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 12 Nov 1999 17:51:44 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: URGENT!!!!!!!!!!!!!!
Message-Id: <80hk3g$lvh$1@internal-news.uu.net>
Mark Bluemel <mark.bluemelNOmaSPAM@siemens.co.uk.invalid> wrote:
> In article <80hd4q$i14$1@internal-news.uu.net>, Erik van Roode
> <newsposter@cthulhu.demon.nl> wrote:
>> 16:53:50 CET
> I think your system clock is wrong.
> It's 15:45:58 GMT
Date: Fri, 12 Nov 1999 07:56:10 -0800
You sure it's not your clock that's 10 minutes off?
Erik
------------------------------
Date: Fri, 12 Nov 1999 10:42:38 -0800
From: "Mark Ruedy" <mruedy@alidian.com>
Subject: Win32::Process problem
Message-Id: <382c5e64$0$221@nntp1.ba.best.com>
Hi,
I am trying to create a process using Win32::Process->Create()
I have tried the following script with both ActivePerl build 522 and nsperl
(Oct 5, 1999) and I get the same message:
1
2 &mysub;
3
4
5 sub mysub {
6 use Win32::Process;
7
8 Win32::Process->Create($proc, 'C:\\winnt\\Notepad.exe',
9 "Notepad perlnut.txt", 1, DETACHED_PROCESS, ".");
10 }
11
Result:
N:\perl\nsPerl5.004_05\bin>.\perl "N:\program files\bin\b.pl"
Usage: Win32::Process::Create(cP,appname,cmdline,inherit,flags,curdir) at
N:\pro
gram files\bin\b.pl line 8.
I copied lines 6 and 8/9 right out of O'Reilly's Perl in a Nutshell book,
page 585. As far as I can see, my usage is correct.
Where can I find help on running perl's Win32 and perl modules in general?
Thanks
------------------------------
Date: Fri, 12 Nov 1999 11:28:11 -0500
From: "Crawfishy" <cans1@hotmail.com>
Subject: Writing data to file on another server.
Message-Id: <_0YW3.1705$h22.6433@newsfeed.slurp.net>
I am writing a cgi script in perl that currently gets data from an html form
and writes it to a data file. This works great but now I need the script to
write the data to a file on another server. Here is the situation in a bit
more detail:
Current scenario:
* HTML Form and CGI Program located on www.somesite.com (ficticious domain)
* Data is currently written to data.db in the same directory as the html and
cgi files.
Desired scenario:
* HTML Form and CGI Program located on www.somesite.com (ficticious domain)
* My computer is running a small server progam on a static IP of
120.121.122.123 (ficticious ip)
* Data would be written to a file located at http://120.121.122.123/data.db
Any input would be greatly appreciated.
George
------------------------------
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 1362
**************************************