[7619] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1245 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 29 15:14:26 1997

Date: Wed, 29 Oct 97 12:00:54 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 29 Oct 1997     Volume: 8 Number: 1245

Today's topics:
     Call cheaper, call Callback! mmwxdoft@force1.net
     Re: CGI tools <rootbeer@teleport.com>
     Re: DBD-Oracle-0.47.tar.gz corrupted? <ramon@ramonc.icix.net>
     Debian & Perl recent versions? (Helmut Jarausch)
     Re: detecting reload <rootbeer@teleport.com>
     Re: Environment <rootbeer@teleport.com>
     Execution time in Perl <us011769@interramp.com>
     Re: Execution time in Perl (Jeremy D. Zawodny)
     Re: Execution time in Perl <seay@absyss.fr>
     Re: Filehandles and nested-if-loops <rootbeer@teleport.com>
     Fly using help??? <s9500643@knut.kumoh.ac.kr>
     Re: fork() makes me wait (?) <peter@preview.org>
     Re: Help me optimize this functionality? <usenet-tag@qz.little-neck.ny.us>
     Re: Help!  with recursion and directories (Gregory Snow)
     how do I save an array into a file? (Sylvain Juneau)
     Re: In-Line images and perl <rootbeer@teleport.com>
     Re: In-Line images and perl <blintz@com.nicorinc>
     Re: In-Line images and perl <rootbeer@teleport.com>
     Re: In-Line images and perl <blintz@com.nicorinc>
     Re: In-Line images and perl <jbokma@caiw.nl>
     Re: Interesting PERL command - need help (Jason Gloudon)
     Re: Let's try this again - Help with Error <rootbeer@teleport.com>
     Re: Memory problems - how can I fix? <rootbeer@teleport.com>
     Module conflict (Phil Glatz)
     Re: Perl 5.004 and HP-UX <rootbeer@teleport.com>
     Re: perl editor (Steve Brant)
     Re: Perl XS interface library linkage <bruce@rose.hp.com>
     reg exp matching <erac.eramsva@memo.ericsson.se>
     Re: reg exp matching (Toutatis)
     Re: shtlm problem though perl works (Kris Carroll)
     Re: Simulating ${parm:-$parm2} <rootbeer@teleport.com>
     Re: String manipulation - Help Required <rootbeer@teleport.com>
     Useless use of sort in void context <jfryan@mdbusiness.com>
     Re: Useless use of sort in void context (Mike Heins)
     Userid and passwords (SHAILKUMAR)
     Re: using -s to get file size <rootbeer@teleport.com>
     Re: using -s to get file size (Charles DeRykus)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 29 Oct 1997 18:39:05 GMT
From: mmwxdoft@force1.net
Subject: Call cheaper, call Callback!
Message-Id: <637vs9$8jk@buck.innerx.net>


Have a boy-friend far away? Wanna call but it's to expencive?
Hey, use our service, call for less. Up to 80% savings!
http://www.spck.se/callback



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

Date: Wed, 29 Oct 1997 09:19:29 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Martien Verbruggen <mgjv@comdyn.com.au>
Subject: Re: CGI tools
Message-Id: <Pine.GSO.3.96.971029091903.25358M-100000@usertest.teleport.com>

On 28 Oct 1997, Martien Verbruggen wrote:

> If you're looking for super speed, you probably shouldn't be using
> perl.  Something compiled would most likely be better (C, C++).

If you're looking for super speed, you should make your own custom
hardware. :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Wed, 29 Oct 1997 13:43:59 -0500
From: Ramon Castillo <ramon@ramonc.icix.net>
To: faust@wwa.com
Subject: Re: DBD-Oracle-0.47.tar.gz corrupted?
Message-Id: <345783EF.6567@ramonc.icix.net>

Faust Gertz wrote:
> 
> On 28 Oct 1997 11:48:50 -0700, lmulcahy@nyx.net (Larry Mulcahy) wrote:
> 
> >I've tried to download this half a dozen times and each time I wind up
> >with something that (gnu) zcat doesn't recognize.  Yes, I know about
> >setting FTP to binary mode, though I've mostly been trying to do this
> >from Netscape.
> 
> That may be your problem.  I have had problems with Nutscrape
> insisting on downloading files in ASCII mode when I have tried to
> specify they be downloaded in binary mode.  Since you know all about
> binary and ASCII mode and apparently suspect that Nutscrape could be
> to blame, why don't you try using a solid FTP program instead of a web
> browser to do your file transfers.
> 
> Just a thought . . .
> 
> Faust Gertz
> Philosopher at Large

I'm agree with Faust and allow his cixelsyd *today*. I downloaded it
FTPing to CPAN and I used gunzip instead zcat probably is not a
cathedratic solution but might be good way around it.

RC
  
-- 
#!/usr/local/bin/perl

use Heart::WithBrain;
while ($god->bless == $Internet && $Perl == $Cool){
       $Be = "Happy";
       $Live = "Love";
       $Hack = "Fun";
}      #  RC          ray@icix.net


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

Date: 29 Oct 1997 17:22:54 GMT
From: jarausch@numa1.igpm.rwth-aachen.de (Helmut Jarausch)
Subject: Debian & Perl recent versions?
Message-Id: <637rde$h6l$1@news.rwth-aachen.de>

Hi,
does anybody know how to get or produce a Debian package with recent
versions of perl / suidperl (5.004_04) and Perl/Tk402.003

www.debian.org only has perl5.004.02 and perl-tk_400.202.

Is there a Perl script to update such a package.

Thanks,
Helmut.


-- 
Helmut Jarausch
Lehrstuhl f. Numerische Mathematik
Institute of Technology, RWTH Aachen
D 52056 Aachen, Germany


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

Date: Wed, 29 Oct 1997 09:05:17 -0800
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: detecting reload
Message-Id: <Pine.GSO.3.96.971029090331.25358I-100000@usertest.teleport.com>

On Tue, 28 Oct 1997, Mike Rambour wrote:

>  Is there a way to detect a reload, 

Not really. But if you want to prevent duplicate entries (in a database or
guestbook, for example) just don't store any duplicate entries. :-)  Hope
this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Wed, 29 Oct 1997 09:22:33 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Patrick Seal <patseal@hyperhost.net>
Subject: Re: Environment
Message-Id: <Pine.GSO.3.96.971029091958.25358N-100000@usertest.teleport.com>

On Tue, 28 Oct 1997, Patrick Seal wrote:

> How do I make a directory a perl library?

The same way that you can make a silk purse into a sow's ear: It's not
possible. :-)

> I have a virtual server and need to make a perl library
> within my directory tree:

Maybe you want this entry from the FAQ?

    http://www.perl.org/CPAN/doc/FAQs/FAQ/html/perlfaq8/
          How_do_I_kep_my_own_module_libr.html

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Wed, 29 Oct 1997 12:23:58 -0500
From: cjz <us011769@interramp.com>
Subject: Execution time in Perl
Message-Id: <3457712D.D21178F7@interramp.com>

Hello,
I am trying to find a way to time the execution of a script.  At this
time I have implemented something very simple that grabs the "time" in
seconds at the start of the scripts and grabs it again at the end,
compares them and prints out the time in seconds.

I am looking for a way to measure the execution time more accurately,
say in 10ths, 100ths, 1000ths etc. of a second.  Please help.

Thanks,

-Eddy



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

Date: Wed, 29 Oct 1997 17:29:02 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: Execution time in Perl
Message-Id: <3457721d.2171141@igate.hst.moc.com>

[cc'd automagically to original author]

On Wed, 29 Oct 1997 12:23:58 -0500, cjz <us011769@interramp.com>
wrote:

Please do not post to comp.lang.perl. It is a dead group.

>Hello,
>I am trying to find a way to time the execution of a script.  At this
>time I have implemented something very simple that grabs the "time" in
>seconds at the start of the scripts and grabs it again at the end,
>compares them and prints out the time in seconds.
>
>I am looking for a way to measure the execution time more accurately,
>say in 10ths, 100ths, 1000ths etc. of a second.  Please help.

If you're on a Unix platform, you may be able to use the 'time'
command to do that.

% time perl script.pl

Jeremy
-- 
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio

http://www.marathon.com/

Unless explicitly stated, these are my opinions only--not those of my employer.


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

Date: Wed, 29 Oct 1997 18:36:22 +0100
From: Doug Seay <seay@absyss.fr>
To: cjz <us011769@interramp.com>
Subject: Re: Execution time in Perl
Message-Id: <34577416.5E2B0798@absyss.fr>

[posted and mailed]

Removed the dead comp.lang.perl newsgroup.

What is pl.comp.lang.perl?  A polish language newsgroup?  My server
doesn't know it, so I'm considering it to be junk and removing it too.  

cjz wrote:

> I am looking for a way to measure the execution time more accurately,
> say in 10ths, 100ths, 1000ths etc. of a second.  Please help.

What do you need that "times" doesn't give you?  "times" is a builtin in
bash and may exist in other shells too.  I haven't used the others
recently enough to remember.  It gives 100th of a second results.

There is also a "timex" command that gives the same accuracy.

Of course, neither of these are Perl specific.

- doug


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

Date: Wed, 29 Oct 1997 09:47:18 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Joseph June <jjune@midway.uchicago.edu>
Subject: Re: Filehandles and nested-if-loops
Message-Id: <Pine.GSO.3.96.971029093714.25358R-100000@usertest.teleport.com>

On Tue, 28 Oct 1997, Joseph June wrote:

> Currently I'm reading in a file to an filehandle via
> 
> while ($rulefile_line = <RULEFILE> ...

You should really use defined() in there, and in fact, Perl will remind
you about that if you ask for warnings.

    while (defined($rulefile_line = <RULEFILE>)) { ... }

> because i need to insert a generated potion into an file.  I am writing
> to the file by using syswrite... 

I'm not sure why you're using syswrite. Won't print do the job more
easily?

> if ($syswrite_hidden == 1) {
> syswrite(ADDRX, $rulefile_line, length($rulefile_line));

Are you checking for partial writes? See perlfunc(1)'s entry on syswrite.

> The problem I am having is that because the nested if loop reads the next
> <RULEFILE>, the syswrite does not write that particular line into the new
> file.  So the new file generated has blank lines... which were basically
> the lines that were "read" by the nest if loop.  

Well, this sounds like you want to use a different technique. For example,
maybe something like this?

    my $printing = 1;				# a flip-flop
    while (<RULEFILE>) {
        $printing = 0 if /some_text/;		# turn off printing
	if (/something_else/) {	
	    $printing = 1;			# turn on printing
	    print ADDRX $other_stuff;		# and insert something
	}
	if ($printing) {
	    print ADDRX;
	} else {
	    # maybe do something else?
	}
    }

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Thu, 30 Oct 1997 02:49:48 +0900
From: SukMoon Lee <s9500643@knut.kumoh.ac.kr>
Subject: Fly using help???
Message-Id: <3457773C.708C6088@knut.kumoh.ac.kr>

Hello.
This program can't display digit color.
but digit graphics display is very well.

Why??

-- source
 ...
$xsize=length($count)*10;
$ysize=16;
srand($count);

open(FLY,"> $infile");
print FLY "new\n";
print FLY "size $xsize,$ysize\n";
print FLY "fill 1,1,255,255,255\n";
for($i=0;$i<=length($count);$i++) {
        $j=substr($count,$i,1);
        $r=$i*5;
        $g=$i*6;
        $b=$i*7;
        $xx=$i*10+1;
        print FLY "string $r,$g,$b,$xx,3,giant,$j\n";
}
close(FLY);
 ...
--
http://knut.kumoh.ac.kr/~s9500643/
mailto:s9500643@knut.kumoh.ac.kr


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

Date: Wed, 29 Oct 1997 10:40:49 -0800
From: "Peter Tiemann" <peter@preview.org>
Subject: Re: fork() makes me wait (?)
Message-Id: <637vpk$jg5$1@ha2.rdc1.sdca.home.com>

>Try closing the three standard filehandles in the child, just after the
>fork, so that the server will know to not expect anything from them. Hope
>this helps!


 ..close (STDxxx)..

That was it - seems that the web server waited for that.
Thanks to everybody who replied.

Peter Tiemann



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

Date: 29 Oct 1997 19:46:26 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Help me optimize this functionality?
Message-Id: <eli$9710291434@qz.little-neck.ny.us>

Jonathan Feinberg <jdf@pobox.com> wrote:
> mattias.lonnqvist@-NO-SPAM-.uidesign.se said...
> > Currently I have a small function which translates certain sequences of
> > chars, or to be precise, it translates %0a - %ff to upper caps.
> s/(\%[0-9a-f][0-9a-f])\b/\U$1/g;
 ...
>     \b  # only if that's the whole word (e.g., not %4cats)

Um, why the \b? That was not in the original problem specification,
and if he is using this for URL stuff it is plain wrong. If I see
a request for "/%7eeli/writings.html" in my web logs, I would want
it to be fixed to "/%7Eeli/writings.html" by any code fragment written
to Mattias' specs.

Elijah
------
wondering if "s/%((?!\d\d)[\da-f][\da-f])/%\U$1/g" would be faster


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

Date: 29 Oct 1997 18:54:46 GMT
From: snow@biostat.washington.edu (Gregory Snow)
Subject: Re: Help!  with recursion and directories
Message-Id: <6380pm$1g62$1@nntp6.u.washington.edu>

In article <34568C56.ABD@cornell.edu>, Tim  <tjt3@cornell.edu> wrote:
>I wrote a Perl script to look for core dumps and emacs ~ files a while
>ago.  I want to modify it so it goes to my user directory and
>recursively chdir()'s to each subdirectory, looking for core and *~
>files in each, deleting them, and logging the results.
>
>I can do everything but the recursion, and I have stuffed all the
>operations to be done in each directory into subroutines.  Duh.  But how
>do I either:
>
>spawn a process for each directory found, and have it repeat until each
>process has run out of subdirectories beside . and .., then kill them?
>
>or
>
>something simpler where I don't have to use child processes?
>
>Any advice would be greatly appreciated!  I will check the newsgroup,
>but if you felt like cc'ing me an email, I'd appreciate that.

I wrote a similar script, it starts from the current directory and
does not do the logging, but it looks for the files you mentioned
(plus others) and gives you options on deleting.

It is at: http://www.biostat.washington.edu/~snow/programs/index.html
You are welcome to copy it and add the modifications you need, or look
at it to see how to do the recursion.


>Thanks in advance to anyone who helps.

Sure, glad I can help (most posts here are beyond me)

>-- 
>Tim
>
>"We don't like their sound, and guitar music is on the way out."
>        --Decca Recording Co. rejecting the Beatles, 1962.

-------------------------------------------------------------------------------
     Gregory L. Snow         | SHAW'S PRINCIPAL:
     (Greg)                  |   Build a system that even a fool can use,
snow@biostat.washington.edu  |   and only a fool will want to use it.
-------------------------------------------------------------------------------


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

Date: Wed, 29 Oct 1997 19:55:12 GMT
From: sylvain.juneau@ec.gc.ca (Sylvain Juneau)
Subject: how do I save an array into a file?
Message-Id: <345793c3.866606@news.cmc.ec.gc.ca>

how do I save an array into a file?


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

Date: Wed, 29 Oct 1997 09:34:03 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ben Holness <bholness@nortel.ca>
Subject: Re: In-Line images and perl
Message-Id: <Pine.GSO.3.96.971029093126.25358P-100000@usertest.teleport.com>

On Wed, 29 Oct 1997, Ben Holness wrote:

> -Perhaps someone has some source code for a web counter in PERL that
> I could base my program on? :)

I think you could use the methods in Randal's thirteenth Web Techniques
column, which explains how to make a "non-visitor counter". Hope this
helps!

   http://www.stonehenge.com/merlyn/WebTechniques/

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Wed, 29 Oct 1997 12:01:04 -0600
From: Brian Lintz <blintz@com.nicorinc>
Subject: Re: In-Line images and perl
Message-Id: <345779E0.78F8@com.nicorinc>

Ben Holness wrote:
> Does anyone know how to make perl output as an inline image?
> [...]
> I thought it would be possible simply to open the image file and then
> output it to html, but this did not seem to work.

Essentially this:

#!/usr/bin/perl

print "Content-type: image/gif\n\n";

open(GIF, "file.gif");
while(<GIF>) {
	print;
}
close(GIF);

-- 
Brian Lintz
WebMaster - Nicor Gas, Inc.


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

Date: Wed, 29 Oct 1997 10:47:45 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Brian Lintz <blintz@com.nicorinc>
Subject: Re: In-Line images and perl
Message-Id: <Pine.GSO.3.96.971029104721.25358X-100000@usertest.teleport.com>

On Wed, 29 Oct 1997, Brian Lintz wrote:

> open(GIF, "file.gif");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check of the return value after opening a
file. Thanks!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Wed, 29 Oct 1997 13:06:26 -0600
From: Brian Lintz <blintz@com.nicorinc>
Subject: Re: In-Line images and perl
Message-Id: <34578932.734F@com.nicorinc>

> On Wed, 29 Oct 1997, Brian Lintz wrote:
> > open(GIF, "file.gif");
 
Tom Phoenix wrote:
> Even when your script is "just an example" 
>(and perhaps especially in that
> case!) you should _always_ check of the return value after opening a
> file. Thanks!

*nods*  You know, I thought about that...

Trouble is, when you're already sending out a content type of image/gif,
the user won't be able to read what the die message was... ya know?

I had it in there to begin with, and took it out for that reason ...

-- 
Brian Lintz
WebMaster - Nicor Gas, Inc.


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

Date: 29 Oct 1997 19:26:33 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: Re: In-Line images and perl
Message-Id: <01bce4a0$6ee78c20$02521e0a@tschai>



Ben Holness <bholness@nortel.ca> wrote in article
<34573554.2BD1@nortel.ca>...
> Hi
> 
> Does anyone know how to make perl output as an inline image?
> 
> As always, an example will make things clearer:
> 
> Perhaps you know how a web page counter works? you have
> <img src="cgi-bin file">, and the cgi file outputs an image.
> I would like to do a similar thing in perl, but it is not a counter
> for web pages, hence I cannot use the web-page counters.
> 
> I thought it would be possible simply to open the image file and
then
> output it to html, but this did not seem to work.
> 
> Any suggestions would be appreciated.
> 
> -Perhaps someone has some source code for a web counter in PERL
that
> I could base my program on? :)

See my 'Logging visitors' tutorial in the Programming section of my
homepage:
http://www.caiw.nl/~jbokma.

If you just want to return an image, use:

print "Location: url-of-the-image\n\n";

print "Content-type: image/gif\n\n";

open(FILE, "theImage.gif");
while(<FILE>) { print; }
close(FILE);

Both should work.

Regards,

John


-- 
----------------------------------------------------------------------
------
C A S T L E  A M B E R      Freelance Software Development
(Java/Perl/C/CGI)
http://www.caiw.nl/~jbokma/ [Java demo's,Perl scripts,Xara graphics,
Resume]
mail:jbokma@caiw.nl         phone: +31 10 4291827



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

Date: 29 Oct 1997 17:37:48 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: Interesting PERL command - need help
Message-Id: <637s9c$923$1@daily.bbnplanet.com>

shiva mantri (smantri@osf1.gmu.edu) wrote:
: open (MAIL, "|");

: is wrong. "|" is pipe command like in UNIX. if u dont have any arguments
: after | it wont do any thing. 

: "|" its a pipe command. anything on the left side of the | command will be
: output to the arguments on the right side. so if u dont have anything on
: rightside it wont do anything. 

: some common | commands 
: ls | lpr -Psomething ///to print the output to a printer
: cat filename | mail username  // to mail the contents of a file to a
: user..

: so when u used MAIL | mail username it sent a mail..

You forgot to say do this : 
 open (MAIL, "|") or die "Can't fork : $!";

and to check whether or not the child process is actually created 
by adding this as well:

local $SIG{PIPE} = sub { die "spooler pipe broke" };

Read the perlipc mangpage and pay attention to the section on 
Using open() for IPC.

Jason Gloudon


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

Date: Wed, 29 Oct 1997 09:18:05 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Henry Hwangbo <skooky@primenet.com>
Subject: Re: Let's try this again - Help with Error
Message-Id: <Pine.GSO.3.96.971029091713.25358L-100000@usertest.teleport.com>

On 28 Oct 1997, Henry Hwangbo wrote:

> Can't load '/usr/local/lib/perl5/site_perl/sun4-solaris/auto/Msql/Msql.so'
> for module Msql: ld.so.1: perl: fatal: relocation error: symbol not found:
> stack_sp: referenced in
> /usr/local/lib/perl5/site_perl/sun4-solaris/auto/Msql/Msql.so at
> /usr/local/lib/perl5/DynaLoader.pm line 140.
> 
>  at /usr/local/lib/perl5/Msql.pm line 87
> BEGIN failed--compilation aborted at dbquery.pl line 70.
> 
> Any ideas with this?  

The module isn't compiled or installed correctly for your current Perl
binary. Try again, and make sure that 'make test' doesn't report any
errors. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Wed, 29 Oct 1997 09:14:19 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ryan <wwolfe@netcom.com>
Subject: Re: Memory problems - how can I fix?
Message-Id: <Pine.GSO.3.96.971029091138.25358K-100000@usertest.teleport.com>

On Tue, 28 Oct 1997, Ryan wrote:

> foreach (1..100000) {

As Ilya has pointed out, in current versions of Perl, this becomes a list
of 100000 scalars at compile time - and they stick around for your entire
script! My rule of thumb is that, if a list from .. may have more
than about 1000 elements, you should code it explicitly with something
like the three-part for loop.

    for ($_ = 1; $_ <= 100000; $_++) {

Does that fix (most of) your memory problem?

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Wed, 29 Oct 1997 18:13:40 GMT
From: phil@glatz.com (Phil Glatz)
Subject: Module conflict
Message-Id: <34577c26.10935502@news.greatbasin.net>

I have a perl CGI that interfaces with the mySQL database.  I use
MySQL.pm to connect, works fine.  However, if I use CGI::Request, I
get the following error:

Base.pm: "my" variable $sn masks earlier declaration in same scope at
/usr/local/lib/perl5/site_perl/CGI/Base.pm line 591.
Base.pm: "my" variable $qs masks earlier declaration in same scope at
/usr/local/lib/perl5/site_perl/CGI/Base.pm line 601.

Not sure why this is happening, any way around it?

------------------------------------------
Phil Glatz                (phil@glatz.com)
Software Engineer       Lake Tahoe, Nevada
WWW: http://www.glatz.com/acme


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

Date: Wed, 29 Oct 1997 09:30:01 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Yves RUIN <ruin@lseet.univ-tln.fr>
Subject: Re: Perl 5.004 and HP-UX
Message-Id: <Pine.GSO.3.96.971029092840.25358O-100000@usertest.teleport.com>

On Tue, 28 Oct 1997, Yves RUIN wrote:

> lib/io_sock........IO::Socket::INET:       Bad hostname 'localhost'   
> ....propagated at ./lib/io_sock.t line 55

I'd guess that DNS isn't set up properly on your machine. Check that a
command like 'nslookup localhost' comes up with an address like 127.0.0.1. 
If you're not sure about setting up DNS, check with your system's docs or
a newsgroup about your system. Good luck! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Wed, 29 Oct 1997 13:40:27 -0500
From: srbrant@mmm.com (Steve Brant)
Subject: Re: perl editor
Message-Id: <MPG.ec14d2b6b6bff23989684@news.mmm.com>

In article <344DAB4F.5578A2E3@elnet.msk.ru>, afan@elnet.msk.ru says...
> Where I can download freeware or shareware editor for PERL program 
> (Win'95)?
>    Reply via email please.
> -- 
> Vladimir
> http://www.ipclub.ru
> 
There is a very nice editor that supports color syntax highlighting, as 
well as other features, called UltraEdit.  Try it out.

http://www.idmcomp.com

Steve Brant



Opinions expressed herein are my own and may not represent those of my employer.



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

Date: Tue, 28 Oct 1997 18:11:41 -0800
From: Bruce LaVigne <bruce@rose.hp.com>
To: Brian Flanagan <brian.flanagan@compaq.com>
Subject: Re: Perl XS interface library linkage
Message-Id: <34569B5D.182A5155@rose.hp.com>

I would also appreciate hearing about how to fix Brian's problem, as I
am having
a similar problem.  Here is the output when I run "make test" on my
extension.  If
anyone knows how to get more info about what the unresoved external in
my case
is, I would GREATLY appreciate it (the line 494 reference is just the
Bootstrap):

Please email back, as I don't normally watch this group.  Thanks,

-bruce


$make test
        PERL_DL_NONLAZY=1 /usr/local/bin/perl -I./blib/arch -I./blib/lib
-I/opt/perl5.003/lib/PA-RISC1.1/5.003 -I/opt/perl5.003/lib
test.pl
1..2
Can't load './blib/arch/auto/SmbExt/SmbExt.sl' for module SmbExt:
Unresolved external at /opt/perl5.003/lib/DynaLoader.pm line 140.

 at blib/lib/SmbExt.pm line 494
BEGIN failed--compilation aborted at test.pl line 11.
not ok 1
*** Error code 215

Stop.
$

Brian Flanagan wrote:

> Hi,
>
> I'm trying to use Perl 5.004 XS interface to a 3rd Party
> library on a Linux machine.  I downloaded the latest version
> of C-Scan and Data-Flow and ...
>
> For the 3rd Party library of :
>  ./libdir/libtpl.a and ./libdir/libtpl.so.1.0.0
>
> I used :
>
>   h2xs -x -O ./libdir/tpl.h -L./libdir -ltpl
>
> ...and it created all the files.  I had to edit the typemap
> file, but touched nothing else.
>
>   perl Makefile.PL
>   make
>   make test
>
> ...and it :
>
> Can't load 'tpl.so' for module tpl: File not found at
>  /usr/lib/perl5/i486-linux/5.00401/DynaLoader.pm line 155
>
> What else can I do to further track down the problem?
>
> I also tried to make test_static and got...
>
> ./perl: can't load library 'tpl.so.1.0.0'
> make: *** [test_static] Error 16
>
> I'm not sure why it can't find the library.
> BTW: I also put links to it in the working directory.
> Any help would be appreciated.
>
> -Brian Flanagan.
> email to : brian.flanagan@compaq.com





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

Date: Wed, 29 Oct 1997 17:55:26 +0100
From: "Martin Svanstrvm" <erac.eramsva@memo.ericsson.se>
Subject: reg exp matching
Message-Id: <34576A7E.C15B67BA@memo.ericsson.se>

Hi everyone,

First of all; Isn't this with discussion groups great? I've had quite a
few problems solved with others help. I just hope that someday I will be

able to offer my help....

To the problem;  This is structure of the hash "%abbreviation" I  have:
Elements:

$abbreviation{0}{longform} = "fds"   : $abbreviation{0}{shortform} ="fs"

$abbreviation{1}{longform} = "fds bla bli"   :
$abbreviation{1}{shortform} ="fdsd"
$abbreviation{2}{longform} = "plsfedd"   : $abbreviation{2}{shortform}
="pl"
and so on..

In $title I have a string e.g. "fds bla bli".
I want to create a reg. exp. which replaces "fds bla bli" (from $title)
to "fdsd" which is maximal matched in  $abbreviation{1}{shortform}.
The problem is that, with my current algoritm, "fds bla bli" will first
be changed to "fs bla fs" (when matching $abbreviation{0}{longform}) and
will not match $abbreviation{1}{longform} at all, when the scanning
continues.

Does anyone have any idees?

All help greatly appreciated,

Martin Svanstrvm






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

Date: 29 Oct 1997 18:06:42 GMT
From: toutatis@_SPAMTRAP_toutatis.net (Toutatis)
Subject: Re: reg exp matching
Message-Id: <toutatis-ya023180002910971906420001@news.euro.net>

Martin Svanstrvm" <erac.eramsva@memo.ericsson.se> wrote:

[skipping weird datastructure]

> In $title I have a string e.g. "fds bla bli".
> I want to create a reg. exp. which replaces "fds bla bli" (from $title)
> to "fdsd" which is maximal matched in  $abbreviation{1}{shortform}.
> The problem is that, with my current algoritm, "fds bla bli" will first
> be changed to "fs bla fs" (when matching $abbreviation{0}{longform}) and
> will not match $abbreviation{1}{longform} at all, when the scanning
> continues.

I guess all you have to do is sort the keys in descending order, by length.
for (sort{length($b) <=> length($a)}keys %replacetable){
   $string =~ s/\b$_\b/$replacetable{$_}/g;
}

This way, abbreviations inside longer keys are expanded as well. If you
don't want that, slightly more work has to be done...

-- 
Toutatis


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

Date: 29 Oct 1997 17:43:04 GMT
From: kcarroll@halcyon.com (Kris Carroll)
Subject: Re: shtlm problem though perl works
Message-Id: <637sj8$b4t$1@brokaw.wa.com>

On 10/28/97, Troy Denkinger wrote:
>In article <635dru$42n$1@brokaw.wa.com>, kcarroll@halcyon.com (Kris Carroll) 
wrote:
>>At http://www.horse-country.com/ridindex.shtml
>><P align=center><A
>>HREF="http://206.63.62.61/htbin/imagemap/maps/hcbuttons.map"><IMG
>>SRC="media/hcbuttons.gif" alt="HC List" BORDER=0 ISMAP></A><!--#exec
>>cgi="/cgi-bin/kcarroll/hc_random2.pl"--> </a></p>
>
>You ought to bring this up on a comp.infosystem.www.browser.* group as 
>that is your problem.  The page looks fine on my browser (IE4).  This 
>is so _not_ a perl question.

Sorry, a newbie mistake. Don't even know the right questions/groups to ask 
yet. I did solve my problem by using <table> so all is well. I'll be back 
with real (dumb) perl questions. Thanks.

Kris C.


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

Date: Wed, 29 Oct 1997 09:02:02 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "Valentin C. Briones" <valentin@cssdomain.com>
Subject: Re: Simulating ${parm:-$parm2}
Message-Id: <Pine.GSO.3.96.971029085005.25358G-100000@usertest.teleport.com>

On Tue, 28 Oct 1997, Valentin C. Briones wrote:

> In Perl, what is a short, elegant, legible way of simulating ksh's
> 
>     var=${parm:-$parm2}

If I understand your request correctly, I'd use this:

    $var = defined($parm) ? $parm : $parm2;

But in most cases, if $parm, when defined, is non-zero and non-empty, you
can use this.

    $var = $parm || $parm2;

(But there's some syntax in the works to make this easier to do in a
future version of Perl.) Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Wed, 29 Oct 1997 09:07:33 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Hugh <hnews@harvest-lodge.demon.co.uk>
Subject: Re: String manipulation - Help Required
Message-Id: <Pine.GSO.3.96.971029090621.25358J-100000@usertest.teleport.com>

On Tue, 28 Oct 1997, Hugh wrote:

> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

You should use the CGI.pm module (or a similar one) to help you with this.
It's not just easier...

> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs)
> {
>     ($name, $value) = split(/=/, $pair);
>     $value =~ tr/+/ /;
>     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>     $FORM{$name} = $value;
> }

 ...it also does this properly. :-)  Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Wed, 29 Oct 1997 12:54:25 -0600
From: Joseph Ryan <jfryan@mdbusiness.com>
Subject: Useless use of sort in void context
Message-Id: <878150780.17204@dejanews.com>

With warnings turned on I am getting a sort warning that I do
not understand.

[--WARNING--]
Useless use of sort in void context at ./web-blast.plx line 179

[--PROGRAM EXCERPT--]
001> #!/usr/local/bin/perl -w
 ....
178> if (evaluateBlastResults($blast_type,\@p,\@percent)) {
179>     sort numerically @score;
180> }
 ....
400> sub numerically {
401>     $a <=> $b;
402> }

Anybody seen this one before, or know why I'm getting it.

Thanks,

Joe

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 29 Oct 1997 19:07:16 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: Useless use of sort in void context
Message-Id: <6381h4$e9e$1@vixen.cso.uiuc.edu>

Joseph Ryan (jfryan@mdbusiness.com) wrote:
: With warnings turned on I am getting a sort warning that I do
: not understand.
: 
: [--WARNING--]
: Useless use of sort in void context at ./web-blast.plx line 179
: 
: [--PROGRAM EXCERPT--]
: 001> #!/usr/local/bin/perl -w
: ....
: 178> if (evaluateBlastResults($blast_type,\@p,\@percent)) {
: 179>     sort numerically @score;
: 180> }
: ....
: 400> sub numerically {
: 401>     $a <=> $b;
: 402> }
: 
: Anybody seen this one before, or know why I'm getting it.
: 


Void context always means you are not using some result.

You are not doing anything with the results of 
the sort. It does not sort the array itself -- it only
returns a sorted list.

You want:

	@score = sort numerically @score;

You should also probably place the subroutine above the 
call, or do a 'use subs qw(numerically)' as in some situations
Perl may not know that 'numerically' is a subroutine.

-- 
Regards,
Mike Heins

This post reflects the
opinion of my employer.


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

Date: 29 Oct 1997 18:18:33 GMT
From: shailkumar@aol.com (SHAILKUMAR)
Subject: Userid and passwords
Message-Id: <19971029181800.NAA08278@ladder02.news.aol.com>

When going to certain webpages, a window pops up and prompts the user
to enter his id and password.
If the id and password is correct, another web page is loaded or else a
server message is displayed.

How do you implement this in perl ?

Thank you, for your attention.



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

Date: Wed, 29 Oct 1997 10:09:22 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: JoyDivisin <joydivisin@aol.com>
Subject: Re: using -s to get file size
Message-Id: <Pine.GSO.3.96.971029100733.25358S-100000@usertest.teleport.com>

On 29 Oct 1997, JoyDivisin wrote:

> I'm working on a program to gather file sizes and I'm using -s. It works
> fine within the directory the program runs in but when trying other
> directories, it doesn't return the file size (but it does return the
> file name, though). 

-s should never return the file name; if it's really doing that in the
most recent version of Perl, you should file a bug report. 

Are you specifying the full directory path? If you ask for the size of
file.foo, Perl has no way of knowing that you mean /some/other/file.foo.
Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Wed, 29 Oct 1997 18:29:25 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: using -s to get file size
Message-Id: <EItsp1.JLt@bcstec.ca.boeing.com>

In article <19971029161001.LAA29202@ladder01.news.aol.com>,
JoyDivisin <joydivisin@aol.com> wrote:
>Hi -
>
>I'm working on a program to gather file sizes and I'm using -s. It works fine
> within the directory the program runs in but when trying other directories, it
> doesn't return the file size (but it does return the file name, though).
>
>Both directories are owned by nobody and the program runs as nobody. Even
> running the program as root returns the same result.
>
>I've tried stat as well. While it returns a different number (not the actual
> file size in bytes) within its own directory, it doesn't return the files
> sizes in other directories.
>

Could you be neglecting the directory qualification, e.g.

-s "./other/directory/some_file"


If not, post some code to avoid crackpot answers :)


HTH,
--
Charles DeRykus 


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

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

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