[10105] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3698 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 11 23:07:20 1998

Date: Fri, 11 Sep 98 20:00:19 -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           Fri, 11 Sep 1998     Volume: 8 Number: 3698

Today's topics:
    Re: COBOL and Perl <charles@hankel.mersinet.co.uk>
    Re: Copying subroutines (Jasmin F. Patry)
        English word list for AI application <tboyd@seark.net>
    Re: English word list for AI application (Mark-Jason Dominus)
    Re: History of Perl - round 1 (David Adler)
    Re: History of Perl - round 1 (Michael J Gebis)
    Re: History of Perl - round 1 (Joseph R. Justice)
        How to compare <yangjian@cs.arizona.edu>
    Re: How to compare <nguyend7@msu.edu>
    Re: How to compare (Larry Rosler)
    Re: How to compare (Matthew Bafford)
        I'm tainted and I don't know why <news@paintbot.com>
    Re: I'm tainted and I don't know why (Mark-Jason Dominus)
        Learning perl nguyen.van@imvi.bls.com
    Re: mod_perl looping :-(. (Eric Lee Green)
        Need CGI That allows User to bring a URL with them to n Fotofina@mailcity.com
    Re: Pattern substitution (Andre L.)
    Re: Perl & Java - differences and uses (David Adler)
    Re: Perl & Java - differences and uses (David Adler)
        Possible Perl memory problem (Mark Manning)
        processing the Drop Down Menu (form part) using Perl sc <flanker@sonnet.ru>
    Re: Search/Replace but Not under certain conditions. HO <lama@softcom.net>
    Re: Search/Replace but Not under certain conditions. HO (Ilya Zakharevich)
        Wierd behavior? (Chuck Gadd)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 11 Sep 1998 11:32:59 +0100
From: Charles F Hankel <charles@hankel.mersinet.co.uk>
Subject: Re: COBOL and Perl
Message-Id: <35F8FC5B.2B9544E1@hankel.mersinet.co.uk>

Mark-Jason Dominus wrote:
> 
> In article <35EF1AC7.F1F9B3DC@plano.net>,
> Charles Richmond  <richmond@plano.net> wrote:
> >So perhaps this post meant to reference the Princeton machine.
> 
> It didn't.

Though it did omit LEO, the first real-world step in business computing.

-- 
Charles F Hankel   Wirral   UK
 ------------------------------
Ready, Willing and (avail)Able




------------------------------

Date: Fri, 11 Sep 1998 22:42:27 GMT
From: jfpatry@undergrad.math.uwaterloo.ca (Jasmin F. Patry)
Subject: Re: Copying subroutines
Message-Id: <Ez55qr.C0B@undergrad.math.uwaterloo.ca>

In article <6tbuqs$5un$1@monet.op.net>, Mark-Jason Dominus <mjd@op.net> wrote:
>In article <Ez4pwz.4vq@undergrad.math.uwaterloo.ca>,
>Jasmin F. Patry <jfpatry@undergrad.math.uwaterloo.ca> (me) wrote:
>
>>Better yet, *why* does it work?
[...]
>
>Maybe you could try asking differently?

I should probably have added: as opposed to how a similar example would work
with scalars, arrays, or hashes -- but I assumed people would implicitly
understand that.  My mistake.

To avoid further confusion, perhaps I should ask instead if the following is
correct:

The analogy with the other Perl datatypes that I had been implicity making --
specifically, that the data (function definition, in this case) is modified
"in place" -- doesn't apply to functions.  For example, when you modify a
hash, say, the reference to the hash stays the same:

%foo = ('a'=>'b');
$fooref1 = \%foo;
%foo = ('c'=>'d');
$fooref2 = \%foo;

Now, $fooref1 and $fooref2 are the same, as we would see if we did:

print "$fooref1", "\n", "$fooref2", "\n";

However, with subroutines, it appears that when a subroutine is redefined, a
completely new chunk of memory is allocated for it, and the reference to this
new memory is installed in the symbol table, replacing the reference to the
old subroutine.  

So \&foo (before redefinition) != \&foo (after).  The old subroutine
definition lives on, if references to it exist, because its memory was not
overwritten -- the symbol table entry was just overwritten with the reference
to the new subroutine.

Is this an accurate explanation of "why" my original example (now deleted)
works the way it does, as opposed to how a similar example would work with
scalars, arrays, or hashes?

Jasmin Patry


------------------------------

Date: Fri, 11 Sep 1998 20:22:24 -0500
From: Jordan Boyd-Graber <tboyd@seark.net>
Subject: English word list for AI application
Message-Id: <35F9CCD0.DD1C11F2@seark.net>

Question:

Does anyone know of a simple (yet fairly complete) list of common words,
sorted by function?  i.e. common verbs, nouns, each in seperate lists
that could be easily imported into a compiler format.

I really don't need definitions, just a list of words sorted by format. 
Can anyone help me?  Please reply to e-mail.

jordanbg@yahoo.com


------------------------------

Date: 11 Sep 1998 22:49:50 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: English word list for AI application
Message-Id: <6tcnge$7rm$1@monet.op.net>

In article <35F9CCD0.DD1C11F2@seark.net>,
Jordan Boyd-Graber  <tboyd@seark.net> wrote:
>Does anyone know of a simple (yet fairly complete) list of common words,
>sorted by function?  i.e. common verbs, nouns, each in seperate lists

Look for `wordnet'.  I think it's at Princeton somewhere.


>Please reply to e-mail.

Maybe.



------------------------------

Date: 11 Sep 1998 23:52:43 GMT
From: dha@panix.com (David Adler)
Subject: Re: History of Perl - round 1
Message-Id: <6tcd4b$jh0@news1.panix.com>

On Thu, 10 Sep 1998 16:51:20 GMT, Brent Michalski <perlguy@inlink.com> wrote:

[In re: the new (!) perl keyboard]

>Only $19.95 from Ronco.

Not from Popeil?  :-)

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"You can lead a bigot to water, but if you don't tie him up, you can't
make him drown." - The Psychodots


------------------------------

Date: 12 Sep 1998 00:02:20 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: History of Perl - round 1
Message-Id: <6tcdmc$gea@mozo.cc.purdue.edu>


John Porter <jdporter@min.net> writes:
}Elaine -HappyFunBall- Ashton wrote:
}> Well, actually, having been a UNIX dork for the last oh-so-many aeons, I
}> like not having to reach for that damn 'Shift' key. I generally type
}> from a stream of consciousness (or lack thereof) so I could really care
}> less about a capital letter here or there. 

}You're deluding yourself if you think you're avoiding capitals for any
}reason other than "style".  Because I haven't seen any scarcity of 
}:"<>?~!@#$%^&*()_+{}| characters in your writing (all of which, you
}know, require the use of the Shift key -- at least on most std kbds.)

Although your post does contain ":"<>?~!@#$%^&*()_+{}|", that's not
actually a perl program.  Thus not only are you being pedantic, but
you are now off-topic for the group.  Thank you, come again.

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


------------------------------

Date: 11 Sep 1998 22:35:58 -0400
From: jrj@access.this-is.a-false.address  (Joseph R. Justice)
Subject: Re: History of Perl - round 1
Message-Id: <6tcmme$b34@access2.digex.net>

[Boilerplate warning: The From: address displayed is deliberately
corrupted in an attempt to foil spammers.  My correct e-mail address
has (at the end) "access.digex.net", begins with "jrj", and has an
at-sign in the middle.  Thanks.  -- J]

[Boilerplate warning: NOTICE!  My reading of Usenet newsgroups is
*sporadic* and random in the extreme!  Therefore, if you post a
response here to this article, I may *not* see it!  If you want to
make sure I see your response, please CC me via e-mail with it, and
indicate within it that it has been both posted and e-mailed to me.
Thanks.  -- J]


[P (and M to Elain A.).  -- J]



According to Elaine -HappyFunBall- Ashton  <eashton@bbnplanet.com>:

As long as you're bothering to capitalize and all, might as well
double space after period ending sentences too.  After all, these
aren't u$oft Word documents we're writing.  Y'know?

> since someone mentioned doing a history of perl i have taken an
> interest in actually doing it.  [snip.  -- J].  if you have any fun
> facts, anecdotes, or anything that may be of interest, do send them
> to me. hopefully, we'll do the paper justice.

This isn't a Fun Fact or anything, more of an idea.  I know there've
been interviews, esp. recently, w/ Larry Wall; not sure if there've
been many / any published interviews with other well known Perl
Leading Lights (such as Tom C, Randal S, Tim O'R (for publishing the
Camel, etc in the first place), etc.)  Scan DejaNews, _The Perl
Journal_, etc, Books In Print title or subject guide, and you ought to
hit the bulk of the names of these people.

Anyway, if you're seriously interested in researching this topic,
these are the sorts of people you need to interview.  Don't just ask
for ancedotes and wait for people to react; come up with some
theories, topic theses, etc, and interview people (if your budget
doesn't allow for F2F interviews, talk to 'em over the phone or by
e-mail), proactively get the info you need.

I know, I know, this is unsolicited Male Answer Syndrome-y comment,
but, hey, that's how I am.

Oh, and a question.  Is this meant to be a thesis like for a Master's
or Doctoral degree, or for an academic / scholarly journal,
e.g. something with a known limited audience, or are you writing for a
larger and broader audience, something that could become a FAQ or
regularly reposted document, or a Web page, or perhaps a feature
article in a more popular magazine (such as, hey, _The Perl Journal_!
:-).  'Cause, depending on your intentions, you know that what you're
gonna write about, how you're gonna write it, your sourcing and
attributions, etc are gonna differ significantly.  Right?

FWIW, I wish you luck with this.  I'm certainly the farthest thing
from a Perl guru, and I'm sure I'd find a article or paper on this
topic (at least if it wasn't *too* dense) to be interesting and
probably quite educational!  I bet a *lot* of other people would find
your work the same way, too.

Good luck, be well, keep us all informed.

Joseph, has Male Answer Syndrome and is bold, proud, and unrepentent
about it.

-- 
	  Joseph R. Justice  ==  jrj, at access.digex.net ==
     an69616, at anon.penet.fi == anon-16439, at anon.twwells.com
 (EFNet) IRC: jrj, jrjx, jrjxx      http://www.access.digex.net/~jrj
 I have a job!  Now if I can keep it...  Next up, the *Personal Ad*!


------------------------------

Date: Fri, 11 Sep 1998 18:00:35 -0700
From: Jian Yang <yangjian@cs.arizona.edu>
Subject: How to compare
Message-Id: <35F9C7B3.705A@cs.arizona.edu>

How to compare $ARGV[0] == 's'?
like this 

if ($ARGV[0] == 's') print ....

or like this

if ($ARGV[0] == "s") print ....

NEITHER works!


------------------------------

Date: 12 Sep 1998 01:19:12 GMT
From: Dan Nguyen <nguyend7@msu.edu>
Subject: Re: How to compare
Message-Id: <6tci6g$mk7$1@msunews.cl.msu.edu>

Jian Yang <yangjian@cs.arizona.edu> wrote:
: How to compare $ARGV[0] == 's'?
: like this 

: if ($ARGV[0] == 's') print ....

: or like this

: if ($ARGV[0] == "s") print ....

: NEITHER works!

try using
if ($ARGV[0] eq "s") print ....

-- 
           Dan Nguyen            | There is only one happiness in
        nguyend7@msu.edu         |   life, to love and be loved.
http://www.cse.msu.edu/~nguyend7 |                   -George Sand



------------------------------

Date: Fri, 11 Sep 1998 18:13:20 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to compare
Message-Id: <MPG.10636a8aed1b5b3898984a@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <35F9C7B3.705A@cs.arizona.edu> on Fri, 11 Sep 1998 18:00:35 -
0700, Jian Yang <yangjian@cs.arizona.edu> says...
> How to compare $ARGV[0] == 's'?
> like this 
> 
> if ($ARGV[0] == 's') print ....
> 
> or like this
> 
> if ($ARGV[0] == "s") print ....
> 
> NEITHER works!

Each one is both the same. :-)

If NEITHER works, it is because the value of $ARGV[0] is not 's'.  There 
are several ways to find out what it really is.  Here are the simplest:

Check that

length($ARGV[0]) == 1

and

print "|$ARGV[0]|\n";

If that doesn't give you the answer, try unpacking to hex, etc.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Fri, 11 Sep 1998 21:44:08 -0400
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: How to compare
Message-Id: <MPG.10639bf0abba5e22989693@news.south-carolina.net>

In article <35F9C7B3.705A@cs.arizona.edu> on Fri, 11 Sep 1998 
18:00:35 -0700, Jian Yang (yangjian@cs.arizona.edu) pounded in 
the following text:
=> How to compare $ARGV[0] == 's'?
=> like this 
=> 
=> if ($ARGV[0] == 's') print ....
=> 
=> or like this
=> 
=> if ($ARGV[0] == "s") print ....
=> 
=> NEITHER works!
=> 

First step, use -w.  -w is your friend.  -w would have told you 
this:

Argument "s" isn't numeric in eq at foo line xxx.

The eq part is a little misleading, but what it's telling you is 
== is for numbers.  "s" is _not_ a number (last time I checked).

What you want is eq.

Hope This Helps!

--Matthew


------------------------------

Date: Fri, 11 Sep 1998 18:50:50 -0400
From: "Paintbot" <news@paintbot.com>
Subject: I'm tainted and I don't know why
Message-Id: <6tc9gh$a28$1@holly.prod.itd.earthlink.net>

I'm getting strange tainting problems with the following.  The key here is
that the result of the grep is NOT tainted, but when assigned to an array,
it IS tainted.  I'm just beginning perl, so feel free to be verbose. Thanks.

running the program gives me the following (note files array becomes
tainted):

files:
auth_session_dir:
readdir:
files: 1
grep:
files: 1
auth_session_dir:
Insecure dependency in unlink while running with -T switch at
 ./Library/auth-extra-lib.pl line 337, <USERFILE> chunk 10.


sub RemoveOldSessions
{
local(@files, $file);

print "files: ",&is_tainted(@files),"\n";
print "auth_session_dir: ", &is_tainted($auth_session_dir),"\n";

# Open up the session directory.
opendir(SESSIONDIR, "$auth_session_dir") ||
&CgiDie("Session Directory Would Not Open\n");

# read all entries except "." and ".."
@files = grep(!/^\.\.?$/,readdir(SESSIONDIR));

print "readdir: ",&is_tainted(readdir(SESSIONDIR)),"\n";
print "files: ",&is_tainted(@files),"\n";
print "grep: ",&is_tainted(grep(!/^\.\.?$/,readdir(SESSIONDIR))),"\n";

closedir(SESSIONDIR);

print "files: ",&is_tainted(@files),"\n";
print "auth_session_dir: ", &is_tainted($auth_session_dir),"\n";

# Go through each file
foreach $file (@files)
{
# If it is older than auth_session_length, delete it
        if (-M "$auth_session_dir/$file" >
               $auth_session_length)
        {
                unlink("$auth_session_dir/$file");
        }

}
} # End of RemoveOldSessions




I got the is_tainted from the perlsec man page.

    sub is_tainted {
        return ! eval
    {
            join('',@_), kill 0; # those are two single quotes
            1;
        }
    }





------------------------------

Date: 11 Sep 1998 19:29:38 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: I'm tainted and I don't know why
Message-Id: <6tcbp2$70d$1@monet.op.net>

In article <6tc9gh$a28$1@holly.prod.itd.earthlink.net>,
Paintbot <news@paintbot.com> wrote:
>I'm getting strange tainting problems with the following.  The key here is
>that the result of the grep is NOT tainted, but when assigned to an array,
>it IS tainted.  I'm just beginning perl, so feel free to be verbose. 

First important fact:  Filenames read with `readdir' are always
tainted.

># read all entries except "." and ".."
>@files = grep(!/^\.\.?$/,readdir(SESSIONDIR));

Now, when you run this line, it reads *all* the items out of the
directory, filters them, and assignes them to @files.  Items in @files
are tainted.

But you have exhausted the contents of the directory!  Further reads
from the same directory will return nothing. If you do

	@files = readdir(SESSIONDIR);
	@morefiles = readdir(SESSIONDIR);

the @files gets the names of all the files, and @morefiles gets the
empty list.

This line:

>print "readdir: ",&is_tainted(readdir(SESSIONDIR)),"\n";

is asking whether the items in the empty list is tainted, and of
course none of them are.  Then this line:

>print "files: ",&is_tainted(@files),"\n";

is asking whether any of the filenames are tainted, and they are.  And
then this line:

>print "grep: ",&is_tainted(grep(!/^\.\.?$/,readdir(SESSIONDIR))),"\n";

is asking about the empty list again.

Hope that is what you wanted to know.


------------------------------

Date: Fri, 11 Sep 1998 23:50:30 GMT
From: nguyen.van@imvi.bls.com
Subject: Learning perl
Message-Id: <6tcd05$4tk$1@nnrp1.dejanews.com>

Hi guys,

I just started perl and seen a lot of perl modules out there, but I'm
confused which ones to use, and there are no samples for these modules. Can
you guys help me out?

Thanks
Van

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


------------------------------

Date: 12 Sep 1998 01:04:03 GMT
From: eric@linux-hw.com (Eric Lee Green)
Subject: Re: mod_perl looping :-(.
Message-Id: <9EC6A02D987E9C70.088F5C1E9BD17023.3797F7763B8AC57C@library-proxy.airnews.net>

On 11 Sep 1998 13:25:58 -0500, Leslie Mikesell <les@MCS.COM> wrote:
>In article <80AF224CD57D3D88.432D9442CA02DE3C.538C5EF1EC1C9B94@library-proxy.airnews.net>,
>Eric Lee Green <eric@linux-hw.com> wrote:
>>How can I make Apache and mod_perl quit looping when I have an error
>>in my Perl script? Typical error: I write
>>
>>    foo=$cgi->param('bar');
>>
>>rather than
>>   
>>    $foo=$cgi->param('bar');
>>
>>and all hell breaks loose. 
>
>If you are running mod_perl as a CGI replacement you can test under
>normal cgi execution first by leaving a normal  ScriptAlias for
>one directory and using the PerlHandler for another.

Yes, I'm running mod_perl as a CGI replacement. I don't know anything
about "native" mod_perl besides the fact that my Postgresql connection
should hang around for a few transactions rather than need to be
re-established with each invocation of the CGI script (yes I use the
"$connection ||= ....." syntax on my open) but I know CGI, so
 ... anyhow. 

The problem is that mod_perl seems to restart the error-aborted job
rather than abort it with an error. If I telnet into port 80 and tell
it to GET the buggy script, I get the HTTP header and the HTML top of
job stuff over and over again, ad nauseum. In other words, all the
stuff that was printed up to the point of the above error. This is worse
than a buggy lpd filter script! 

>If you have to resort to brute force you can probably spot the busy
>httpd process with 'top' and kill it.

Since I do all development and testing on my own personal system, I just
do "/etc/rc.d/init.d/httpd restart" and be done with it :-). (on Red Hat
Linux that does a clean shutdown of Apache, then brings it back up
again). I even have a two-letter alias for that line.  

I'll probably just go back and reset the default to just do me plain
CGI while I'm developing, but there has to be a safer way to set up
mod_perl. I hate the thought that an unknown bug in my code might make
my server crash because it went into that "error-retry" loop :-(. 

--
Eric Lee Green         eric@linux-hw.com     http://www.linux-hw.com/~eric
Systems Specialist    Linux Hardware Solutions -- Quality Designed for Linux


------------------------------

Date: Sat, 12 Sep 1998 00:02:56 GMT
From: Fotofina@mailcity.com
Subject: Need CGI That allows User to bring a URL with them to new site.
Message-Id: <6tcdng$6mj$1@nnrp1.dejanews.com>

Hello all:
I have a bit of a challenging question that answer to which is baffling me to
death!

I need to find a script that will allow another webmaster to pass me a url
when one of his visitors comes from his site to mine. For example: the user
is coming to my site to use my photographic services. He must be able to pick
which photo he wants to use from a group of thumbnails once he gets to my
site. These thumbnails don't really exist on my server. These thumbnails are
created dynamically on a page based on who this visitor is and where he's
just come from and the thumbnails are actually on the referring site.

In other words, he "brings" the pictures with him in a sense to my site. When
he arrives on my site a page is built showing all his photos from the other
site and he can pick one. Once he picks one the referring webmaster sends the
selected file to a designated location on my server. See the difficulty of
this one?

I'm hoping this is a really simple one and there may even be a java script
that can handle this. It's tearing me up not being able to figure this one
out though. I'm counting on you guys and gals to save me from severe brain
damage! (grin) Please email replies to the address below as I probably won't
get a chance to visit the group again until I get this resolved!

Harley

icorp@erols.com

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


------------------------------

Date: Fri, 11 Sep 1998 20:36:21 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Pattern substitution
Message-Id: <alecler-1109982036210001@dialup-616.hip.cam.org>

In article <6tc60d$s30$1@nnrp1.dejanews.com>, dzuy@my-dejanews.com wrote:

> In article
> <Pine.OSF.3.96.980911110228.23929A-100000@hilbert1.ms.washington.edu>,
>   Meenu <meenu@ms.washington.edu> wrote:
> > I have following URL
> >        www.aol.com.
> > and what I need to do is delete the (period at end) meaning make it
> >        www.aol.com
> >
> > 1.  I tried using Chop & chomp.. how ever it doesn't work. Can anyone tell
> >    me why it doesn't work?
> > 2. then I tried using the substituion routine
> >     $new_url = ~ s/$./ /;
> 
>         You almost got it right:
> 
>         $url = "www.aol.com."
>         $url =~ s/.$//;         # Get rid of the last .

This won't get rid of the last dot:

a) if the dot is followed by another character, such as a newline;
b) because . can be any character. Maybe you meant /\.$/

Andre


------------------------------

Date: 12 Sep 1998 01:03:44 GMT
From: dha@panix.com (David Adler)
Subject: Re: Perl & Java - differences and uses
Message-Id: <6tch9g$jh0@news1.panix.com>

On Fri, 11 Sep 1998 17:12:10 GMT, George Reese <borg@imaginary.com> wrote:

>Perl IS NOT OO.  It just added some OO constructs as an
>afterthought.

Hmm... Since, if I recall correctly, Perl 5 was rewritten from the
ground up and included references/objects, this seems a bit off.

Just thought you'd all want to know.  :-)
-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"This is Mace's planet.  We Just Live here."


------------------------------

Date: 12 Sep 1998 01:31:26 GMT
From: dha@panix.com (David Adler)
Subject: Re: Perl & Java - differences and uses
Message-Id: <6tcite$jh0@news1.panix.com>

On Wed, 09 Sep 1998 10:28:59 -0400, John Porter <jdporter@min.net> wrote:
>George Reese wrote:
>> 
>> I have never heard anyone argue that Perl must be the
>> best language since if you look at the world you can see Perl in every
>> tree and blade of grass.
>
>Then allow me the honor of being the first to do so.
>
>John Porter

Just thought I'd put this little snippet from irc (not #perl,
surprisingly!) in:

"i gave up on every non-perl language because I had too much real work
to do and it came into my life and painted pretty flowers all over my
walls"

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"I was under medication when I made the decision not to burn the
tapes." - President Richard Nixon


------------------------------

Date: 12 Sep 1998 02:26:27 GMT
From: markem@flash.net (Mark Manning)
Subject: Possible Perl memory problem
Message-Id: <markem-1109982139260001@p138.amax8.dialup.hou1.flash.net>

This is a MAYBE posting.  That is to say that I believe I may have found
something wrong with Perl - but it is more likely that I am just doing
something wrong.

First, the program:

#!/usr/local/bin/perl
#
#  Get the file
#
   open( THEFILE, "myfile.dat" ) || die $!;
   @oldInfo = <THEFILE>;
   close( THEFILE );

   @theInfo = sort @oldInfo;
   undef @oldInfo;
#
#  Remove duplicates
#
   $i = $#theInfo;
   while( $i > 0 ){
      while( $theInfo[$i] eq $theInfo[$i-1] ){
         splice( @theInfo, $i, 1 );
         }

      $i--;
      }
#
#  Remove blank lines
#
   for( $i=0; $i<=$#theInfo; $i++ ){
      if( length($theInfo[$i]) < 5 ){
         splice( @theInfo, $i, 1 );
         }
      }
#
#  Write everything back out.
#
   open( THEFILE, ">myfile.dat" ) || die $!;
   print THEFILE @theInfo;
   close( THEFILE );

   exit( 0 );
#
#####################################################

Ok, here is what the data is like:  It is 60,000,000 bytes or 60MB of
information.  Each line is approximately 100-200 characters long.  What
happens is that memory is used up, the program core dumps, and that's all.

I modified the program so it then would read each line of the file one
after the other and do the above in that method and it works like a dream
and never gets larger than 1,000,000 bytes or 1MB in size.

Here is what I think is happening:

After checking the source code for Perl I found that Perl uses a large
number of shorts.  What I believe is happening is that one or more of
these short variables are being flipped.  That is to say - they are
exceeding the capacity of the short variable to hold how much memory is
being used and this is causing one or more of these variables to revert
back to zero and begin again.  Thus forgetting about the previous
information which was being kept track of.

Additional information:

I originally wrote and tried to use this program on my Macintosh.  I even
went so far as to buy 160MB of memory for the machine.  It continuously
would die with the infamous "Out of memory" message.  So I decided to try
this on my IBM Linux box.  It only had 64MB of memory and a 64MB swap
space.  The program core dumped.  So then I bought and installed PPCLinux
on the Macintosh.  Even with Linux running with 160MB of memory and a
200MB swap area Perl still core dumped.  

Conclusions:

The clincher for me is that, using the same version of Perl (v5.004) on
all three systems caused the same problem.  Also, making the changes so
that the program read a single line from the file and processed them one
after the other also worked very well.

That is to say:  If this were not a problem with something like a short
variable versus a long variable, then the large number of records would
have nothing to do with it.  Perl would consistently reclaim the memory I
release via the UNDEF command or it would consistently die horribly.  But
it doesn't and I feel that the reason for this is because there is so much
information coming in at one time, (something like > 90,000 records) that
the short variable gets exceeded long before Perl even has a chance to do
anything about it.  This is because of the "@oldInfo = <THEFILE>;" line. 
The routine which reads in all of this information probably doesn't allow
any other portion of Perl to even execute until it is finished.

Fini:

Anyway, this is something which has come up repeatedly in the past couple
of months and I just wanted those who work on Perl to know about this. 
Like I've said - I've re-written my routines so that this doesn't affect
me, but it is something which should be looked into.

PS: The program usually died either in the sort or when trying to remove
the duplicates.  Most normally in the sort though.

Later.  E-mail me if you want to talk about this.


------------------------------

Date: Sat, 12 Sep 1998 04:12:49 +0100
From: "Michael Yevdokimov" <flanker@sonnet.ru>
Subject: processing the Drop Down Menu (form part) using Perl script
Message-Id: <6tcdts$mr6$1@bison.rosnet.ru>

Hello!

Can anybody tell me how to process the currect item of drop-down menu box
from <form>...</form> properly and write it to file? May be you send me any
example?

Thanks forward.

Michael




------------------------------

Date: Fri, 11 Sep 1998 18:23:22 -0700
From: "Tdl" <lama@softcom.net>
Subject: Re: Search/Replace but Not under certain conditions. HOW?
Message-Id: <35f9cd2b.0@news.softcom.net>

It's not glamorous, but you could do this:

$body =~ s|(http://\S+)|<a href="$1">$1</a>|g if !/@/;

__Tdl


Ron Bennett wrote in message <6tafq8$ktu$1@news1.epix.net>...
>I've read the groups, faqs, etc and am still mystified as to how to do
this:
>
>$body =~ s|(http://\S+)|<a href="$1">$1</a>|g;
>
>Converts all strings begining with 'http://' to actual hypertext links and
>works fine.
>
>BUT how do I code it so it does NOT match if the http://whatever address
>contains any '@' characters in it??
>
>Ron Bennett
>




------------------------------

Date: 12 Sep 1998 02:25:06 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Search/Replace but Not under certain conditions. HOW?
Message-Id: <6tcm22$rm6$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Larry Rosler
<lr@hpl.hp.com>],
who wrote in article <MPG.10633764802d6b889897a1@nntp.hpl.hp.com>:
> [Posted to comp.lang.perl.misc and a copy mailed.]
> 
> In article <6tbndq$66g$1@mathserv.mps.ohio-state.edu> on 11 Sep 1998 
> 17:42:18 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> says...
> > Oups, one needs to backwack the @-sign:
> > 
> >          http://[^\s\@]+(?!\S)
> 
> Why?

Since the original RE had !-delimiters: 

      s!!!, 

thus *was* interpolated, thus $ and @ should be backwacked - unless
$ is *obviously* a RE metachar.

Ilya


------------------------------

Date: Sat, 12 Sep 1998 00:48:16 GMT
From: cgadd-NO@SPAM-cfxc.com (Chuck Gadd)
Subject: Wierd behavior?
Message-Id: <35f9bf41.151867183@news.csd.net>

HELP!!!!

Here's a short perl script:

#!/usr/bin/perl
$test = chr(255).chr(255).chr(255).chr(255);
$a = unpack("l",pack("L",unpack("V",$test )));
print "signed = $a\n";
$a = unpack("L",pack("L",unpack("V",$test )));
print "unsigned = $a\n";



When run from Perl 5.003, it returns:
signed = -1
unsigned = 4294967295   

But when run from Perl 5.004, it returns:
signed = 4294967295
unsigned = 4294967295

Why??? The signed is coming back as an Unsigned!  




Chuck Gadd
Director of Software Development, Cyber FX Communications.
Remove the -NO SPAM- from my email address to send me e-mail.


------------------------------

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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 3698
**************************************

home help back first fref pref prev next nref lref last post