[27416] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9069 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 20 09:05:49 2006

Date: Mon, 20 Mar 2006 06:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 20 Mar 2006     Volume: 10 Number: 9069

Today's topics:
    Re: A Problem With GD <rwxr-xr-x@gmx.de>
    Re: A Problem With GD <rvtol+news@isolution.nl>
    Re: Finding unused variables in a Perl script <spotturn@gmx.de>
    Re: Finding unused variables in a Perl script <matthew.garrish@sympatico.ca>
        How to release memory ? <zdbrg@mail.con>
    Re: How to release memory ? <rwxr-xr-x@gmx.de>
    Re: How to release memory ? <zdbrg@mail.con>
    Re: How to release memory ? <zentara@highstream.net>
        Measure socket connection time <stefano@#NOSPAMME#3000.it>
    Re: Measure socket connection time <1usa@llenroc.ude.invalid>
        Perl IDE <pengyangl@yahoo.com.cn>
    Re: Perl IDE <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 20 Mar 2006 13:33:46 +0100
From: "Lukas Mai" <rwxr-xr-x@gmx.de>
Subject: Re: A Problem With GD
Message-Id: <dvm7fa$utb$00$1@news.t-online.com>

robic0 schrob:
> On Sun, 19 Mar 2006 13:21:22 +0100, "Lukas Mai" <rwxr-xr-x@gmx.de> wrote:
> 
>>robic0 schrob:
>>> 
>>> Really? What does a compiler know? It knows the smallest and the largest.
>>> The smallest is always a "char", the largest is always an "int".
>>
>>Wrong. The smallest addressable unit is always a char, but long int or
>>long long int are often larger than int.
> 
> Jesus, what drugs are you on dude? I'm talking about the *MACHINE WORD*.
> That which is *NATIVE* to the cpu, a *REGISTER*, address or data !!!!
> These are *INTRINSIC* types to the compiler, there are *NO* others !!!

Wrong again. What makes you think a compiler has to generate machine
code, or that int has to be a "native" type? Or that all registers have
the same size?

> Everything else you can type in a .cpp file is a *MACRO*, a definition
> that resolves to signed or unsigned of the native "char" or "int". This
> since the advent of 32-bit compilers. 

A macro is something created by "#define" (ok, or one of the built-in
macros, like __FILE__ or __STDC__). Oh, and shorts are 16 bits wide
here. That's neither char (8 bits) nor int (32 bits).

> Bit map manipulations are extremely dependent on this and are hardcoded
> by programmers. Bit masks, bit shifts are usually what needs to be modified
> when going to a *larger* machine word compiler.

Only if your code sucks. You can write perfectly portable code that uses
bitwise ops.

> If you see code that has typing other than int, char, signed or unsigned,
> it is a macro! AND its probably code that is 10 or more years older.

Wrong.

> "long" is *NOT* a intrinsic type for many years now. Not "long long",
> "long short long", "short long char", not any of these things!!!!

You can't use both "short" and "long" in the same type. "long" happens
to be an intrinsic type here (it's 32 bits wide and fits in a machine
register).

> Get off drugs as soon as possible..........
> 
> <other bullshit snipped>

As announced, your soul is mine now. I advise you to stop posting to
usenet; no one will pay attention to your articles anyway if you don't
have a soul. Thanks.

Lukas


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

Date: Mon, 20 Mar 2006 14:04:54 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: A Problem With GD
Message-Id: <dvmd16.19k.2@news.isolution.nl>

Lukas Mai schreef:

> Wrong again.

Please don't feed the troll.

-- 
Affijn, Ruud

"Gewoon is een tijger."
echo 014C8A26C5DB87DBE85A93DBF |perl -pe 'tr/0-9A-F/JunkshoP cartel,/'


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

Date: Mon, 20 Mar 2006 10:07:21 +0100
From: Andreas Krause <spotturn@gmx.de>
Subject: Re: Finding unused variables in a Perl script
Message-Id: <dvlrca$7ev$1@athen03.muc.infineon.com>

>>> I'm looking for a module or program to find all declared but unused 
>>> variables in a Perl script.
>>
>>Ever tried perl -w?

Sure :-)

> Yuck, are you secretly advocating making all your variables global?

Not at all. I just want to clean some programs from old variables, which
are no longer used but still declared.

> use warnings;
> $x;
> my $y;
> 
> Useless use of a variable in void context at e:\scripts\undec.pl line 2.
> Name "main::x" used only once: possible typo at e:\scripts\undec.pl line 2.

This just gives me *undeclared but used*, not *unused but declared* variables.
If it would complain about $y, I would be happy...

andi


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

Date: Mon, 20 Mar 2006 06:49:09 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Finding unused variables in a Perl script
Message-Id: <REwTf.3761$ji6.123752@news20.bellglobal.com>


"Andreas Krause" <spotturn@gmx.de> wrote in message 
news:dvlrca$7ev$1@athen03.muc.infineon.com...
>>>> I'm looking for a module or program to find all declared but unused 
>>>> variables in a Perl script.
>>>
>>>Ever tried perl -w?
>
> Sure :-)
>
>> Yuck, are you secretly advocating making all your variables global?
>
> Not at all. I just want to clean some programs from old variables, which
> are no longer used but still declared.
>
>> use warnings;
>> $x;
>> my $y;
>>
>> Useless use of a variable in void context at e:\scripts\undec.pl line 2.
>> Name "main::x" used only once: possible typo at e:\scripts\undec.pl line 
>> 2.
>
> This just gives me *undeclared but used*, not *unused but declared* 
> variables.
> If it would complain about $y, I would be happy...
>

That was my point. Lexically scoped variables will not be picked up by the 
warnings pragma, only globals. What you want can't be done, to my knowledge 
anyway.

Matt 




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

Date: Mon, 20 Mar 2006 11:35:35 +0100
From: zdbrg <zdbrg@mail.con>
Subject: How to release memory ?
Message-Id: <441e8576$0$18989$626a54ce@news.free.fr>

Hello,

Is there a way to release perl unused memory ?

eg: under linux, the following code would not release memory (unlike a similar  
program written in  
C)

perl -e '$m = "m" x 50_000_000; $m = ""; undef $m; sleep 1000'


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

Date: Mon, 20 Mar 2006 13:36:52 +0100
From: "Lukas Mai" <rwxr-xr-x@gmx.de>
Subject: Re: How to release memory ?
Message-Id: <dvm7l4$utb$00$2@news.t-online.com>

zdbrg <zdbrg@mail.con> schrob:
> Hello,
> 
> Is there a way to release perl unused memory ?

perldoc -q shrink

HTH, Lukas


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

Date: Mon, 20 Mar 2006 14:29:04 +0100
From: zdbrg <zdbrg@mail.con>
Subject: Re: How to release memory ?
Message-Id: <441eae1f$0$13031$626a54ce@news.free.fr>

Lukas Mai a dit le Mon, 20 Mar 2006 13:36:52 +0100:

>> Is there a way to release perl unused memory ?
>
>perldoc -q shrink

Thanks for your helpfull answer. (-q memory was useless)

So according to what Is said, lexicals ("my" variables) cannot release their  
memory because "It is reserved in case the variables come back into scope"  
while globals can. 


While I do not understand very well the reasons for this optimization,
This does not seem to be always true :

eg: those 2 exemples show similar memory use under linux :

# global variable example
perl -e 'our $m = "m" x 50_000_000; $m = ""; undef $m; sleep 1000'
# same with lexicals
perl -e 'sub m { my $m = "m" x 50_000_000; undef $m; } &m; sleep 1000'

Also, my perl is compiled with system malloc :
$ perl -V:usemymalloc
usemymalloc='n'
So it should release memory (for globals at least) ...


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

Date: Mon, 20 Mar 2006 13:42:26 GMT
From: zentara <zentara@highstream.net>
Subject: Re: How to release memory ?
Message-Id: <ihat12d7gacd4s82ej11fd00qslh6ijmv4@4ax.com>

On Mon, 20 Mar 2006 11:35:35 +0100, zdbrg <zdbrg@mail.con> wrote:

>Hello,
>
>Is there a way to release perl unused memory ?
>
>eg: under linux, the following code would not release memory (unlike a similar  
>program written in  
>C)
>
>perl -e '$m = "m" x 50_000_000; $m = ""; undef $m; sleep 1000'

Read these links.
http://www.perlmonks.org?node_id=336883

Here is an example of releasing memory in Perl. Most of the time,
you will not be able to get such a simple program, so the best you
can do is to "reuse" memory. 
This example is an exception to how things normally happen.
Perl will generally not release back to the system, until it exits. It
will free the memory internally for it's own reuse, so you need to
devise strategies for reusing namespaces, when using objects.

If you read those links above, you will find out about the "ref count".
Perl only frees the memory, when the ref count for the data structure
assigned to it, goes to zero. In simple programs, like below, it is easy
to do, but in complex programs, where variables and namespaces get
intertwined, it is usually impossible to get the ref count to go to
zero.

In Tk programming, it gets very tangled, and you can only reuse objects
to prevent memory from climbing.  Gtk2 is quite a bit better, and
undef'ing an object usually cleans up after itself and frees the memory 
for reuse. But in a complex script, which use objects, you will probably
never see memory freed back to the OS, until the script exits.

The rule in the following is that the variable must be undefined
within it's scope.

#!/usr/bin/perl -w
use strict;
$| = 1;

{
    my $string;
    for ( 1 .. 100000 ) {
        $string .= ( 'x' x 1000 );
    }
    print "check memory  then press enter to release";
    <>;

   # try running this with the following undef commented out 
    undef $string;    
    print "undefined but still in scope of sub, hit enter\n";

    <>;

    # if the variable only goes out of scope. 
    # you *need* to undef it! 
}

print "ok,out of scope, check mem,  press enter to exit";
<>;
__END__








-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


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

Date: Mon, 20 Mar 2006 13:30:43 GMT
From: Ste <stefano@#NOSPAMME#3000.it>
Subject: Measure socket connection time
Message-Id: <pan.2006.03.20.13.30.43.617593@#NOSPAMME#3000.it>

Hi all,

I've to deploy a (maybe simple) things:

Just open a socket (host 10.10.10.10 port 15000)

Measure the time for socket connection, send "quit" and close.

There's some usefull functions to do it?


Thanks
Ste


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

Date: Mon, 20 Mar 2006 13:36:33 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Measure socket connection time
Message-Id: <Xns978C57B17DC53asu1cornelledu@127.0.0.1>

Ste <stefano@#NOSPAMME#3000.it> wrote in 
news:pan.2006.03.20.13.30.43.617593@#NOSPAMME#3000.it:

> I've to deploy a (maybe simple) things:
> 
> Just open a socket (host 10.10.10.10 port 15000)
> 
> Measure the time for socket connection, send "quit" and close.
> 
> There's some usefull functions to do it?

You can use IO::Socket and time.

Once you have given it a shot, post a short but complete script here if 
you have any problems.

Sinan
-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



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

Date: Mon, 20 Mar 2006 15:43:51 +0800
From: "Pengyang Lu" <pengyangl@yahoo.com.cn>
Subject: Perl IDE
Message-Id: <dvlmle$c2m$1@newshost.mot.com>

Hi,

Does anybody know which Perl IDE software for UNIX should be used?

Best regards,

Pengyang




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

Date: Mon, 20 Mar 2006 06:43:16 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl IDE
Message-Id: <slrne1t8r4.olr.tadmc@magna.augustmail.com>

Pengyang Lu <pengyangl@yahoo.com.cn> wrote:


> Does anybody know which Perl IDE software for UNIX should be used?


   perldoc -q IDE


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V10 Issue 9069
***************************************


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