[27421] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9070 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 20 18:06:15 2006

Date: Mon, 20 Mar 2006 15: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: 9070

Today's topics:
        [ANNOUNCE] Config::Model - Framework for semantic valid <domi@komarr.grenoble.hp.com>
    Re: Can perl check if executable exists <Random@Task.be>
    Re: Can perl check if executable exists <1usa@llenroc.ude.invalid>
    Re: Finding unused variables in a Perl script <rvtol+news@isolution.nl>
    Re: Finding unused variables in a Perl script <corff@zedat.fu-berlin.de>
    Re: How to release memory ? <zdbrg@mail.con>
    Re: How to release memory ? <nospam-abuse@ilyaz.org>
    Re: How to release memory ? <hjp-usenet2@hjp.at>
    Re: Perl IDE <scobloke2@infotop.co.uk>
    Re: Perl IDE <bart.lateur@pandora.be>
    Re: Perl IDE <notanemail@no.com>
    Re: Perl IDE <eflorac@imaginet.fr>
    Re: TCL vs. Perl <matthew.garrish@sympatico.ca>
    Re: XML::Simple and utf8 woes <corff@zedat.fu-berlin.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 20 Mar 2006 15:07:25 GMT
From: Dominique Dumont <domi@komarr.grenoble.hp.com>
Subject: [ANNOUNCE] Config::Model - Framework for semantic validation of  config data
Message-Id: <IwFKq1.23Mp@zorch.sf-bay.org>


Hello

I'm pleased to announce the first release of the Config::Model
(http://search.cpan.org/dist/config-model/) perl module.  

The Config::Model provides a framework to help in validating the
semantic content of configuration data.

How does this work ?
--------------------

Using this project, a typical configuration validation tool will be
made of 3 parts :

   1. The user interface
   2. The validation engine which is in charge of validating all the
      configuration information provided by the user.
   3. The storage facility that store the configuration information

The important part is the validation engine. 

Don't we already have some configuration validation tools ?
-----------------------------------------------------------

You're probably thinking of tools like webmin. Yes, these tools exist
and work fine, but they have their set of drawbacks.

Usually, the validation of configuration data is done with a script
which performs semantic validation and often ends up being quite
complex (e.g. 2500 lines for Debian's xserver-xorg.config script which
handles xorg.conf file). 

In most cases, the configuration model is expressed in instructions
(whatever programming language is used) and interspersed with a lot of
processing to handle the actual configuration data.

What's the advantage of this project ?
--------------------------------------

The Config::Model projects provide a way to get a validation engine
where the configuration model is completely separated from the actual
processing instruction.

The configuration model is expressed in a declarative form (i.e. a
Perl data structure) which is always easier to maintain than a lot of
code.

The declaration specifies:
- the structure of the configuration data (which can be queried by
  generic user interfaces)
- the properties of each element (boundaries, check, integer or
  string, enum like type ...)
- the default values of parameters (if any)
- mandatory parameters
- the targeted audience (intermediate, advance, master)
- on-line help (for ach parameter or value of parameter)
- the level of expertise of each parameter (to hide expert parameters
  from newbie eyes)

So, in the end:
- maintenance and evolution of the configuration content is easier
- user will see a *common* interface for *all* programs using this
  project.
- user will not see advanced parameters
- upgrade of configuration data is easier and sanity check is
  performed
- audit of configuration is possible to check what was modified by the
  user compated to default values

What about the user interface ?
-------------------------------

Config::Model will also come with a Curses::UI interface that queries
the user's model and generate the relevant user screens.

Why an old-fashioned Curses interface ?
To be able to configure your system even if X is not running.

What about data storage ?
-------------------------

Since the syntax of configuration files vary wildly form one program
to another, most people who want to use this framework will have to
provide a dedicated parser/writer. 

Nevertheless, this project can also provide a writer/parser for most
common format: like ini style file, or provide an interface to the
Elektra or debconf projects. This point is open for discussion.

It is entirely possible for a single configuration model to use
several parsers and writers so one model will ensure the consistency
of several configuration files together.


The project homepage is located on sourceforge:
    http://config-model.sourceforge.net/
    http://sourceforge.net/projects/config-model/

Cheers

-- 
Dominique Dumont 
"Delivering successful solutions requires giving people what they
need, not what they want." Kurt Bittner




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

Date: Mon, 20 Mar 2006 14:57:52 -0500
From: Random Task <Random@Task.be>
Subject: Re: Can perl check if executable exists
Message-Id: <0PDTf.2488$qX6.57260@news20.bellglobal.com>

Random Task wrote:
> Hi ...
> 
> I have a perl scrip ...
> 
> It simple calls make ... and does some work after that ...
> 
> Before I call make I would like to see if it is in my PATH. If it is not 
> in my Path i would like to check for make in a couple hardcoded visual 
> studio directories ... i.e. VS .NET or VS6 ...
> 
> Thanks in advance,
> 
> Jim

Thanks all:-)

I ended up calling:

system("command -help")

and then checking the return value :-)

Jim



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

Date: Mon, 20 Mar 2006 20:21:23 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Can perl check if executable exists
Message-Id: <Xns978C9C5492721asu1cornelledu@127.0.0.1>

Random Task <Random@Task.be> wrote in
news:0PDTf.2488$qX6.57260@news20.bellglobal.com: 

> Random Task wrote:
>> Hi ...
>> 
>> I have a perl scrip ...
>> 
>> It simple calls make ... and does some work after that ...
>> 
>> Before I call make I would like to see if it is in my PATH. If it is
>> not in my Path i would like to check for make in a couple hardcoded
>> visual studio directories ... i.e. VS .NET or VS6 ...
>> 
>> Thanks in advance,
>> 
>> Jim
> 
> Thanks all:-)
> 
> I ended up calling:
> 
> system("command -help")
> 
> and then checking the return value :-)

How does that help?

D:\Home\asu1> command -help
Specified COMMAND search directory bad
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.

D>exit

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 18:56:06 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Finding unused variables in a Perl script
Message-Id: <dvmu88.19k.1@news.isolution.nl>

Matt Garrish schreef:

> [find all declared but unused variables]
> can't be done, to my knowledge anyway.

It may be possible for a source that doesn't use eval.

-- 
Affijn, Ruud

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


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

Date: 20 Mar 2006 21:54:37 GMT
From: <corff@zedat.fu-berlin.de>
Subject: Re: Finding unused variables in a Perl script
Message-Id: <488mktFj3jadU3@uni-berlin.de>

Andreas Krause <spotturn@gmx.de> wrote:
: > $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...

Sorry for the useless -w hint; I found out about this behaviour only after
I had posted my message and written a minimal test script.

Oliver.

PS: Perhaps a small varprof.pl utility would be nice.

1. Collect all variables, no matter whether declared or not
2. Count them. $count==1 should, in very naive thinking, indicate
   that they appear only once.
3. Slightly more sophistication is obtained when variables are
   tested for: 
   - do they receive assignments?
   - do they appear on the RHS of assignments and equations?
   - are they used in print and similar statements?


-- 
Dr. Oliver Corff              e-mail:    corff@zedat.fu-berlin.de


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

Date: Mon, 20 Mar 2006 15:41:18 +0100
From: zdbrg <zdbrg@mail.con>
Subject: Re: How to release memory ?
Message-Id: <441ebf0d$0$20943$636a55ce@news.free.fr>

zentara a dit le Mon, 20 Mar 2006 13:42:26 GMT:
>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__

Thanks for that nice example.

I commented out the "undef" as suggested and memory is not released in that  
case, even when it goes out of scope, when memory cannot be reused anymore !  
Isn't that a bug ? Shouldn't the refcount decrease to 0 when leaving the  
variable's scope  
?


Also, When you change the "$string" creation code to :
$string = 'x' x 100_000_000;

Most memory is not released.


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

Date: Mon, 20 Mar 2006 21:28:26 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: How to release memory ?
Message-Id: <dvn6pq$2lj6$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
zdbrg 
<zdbrg@mail.con>], who wrote in article <441eae1f$0$13031$626a54ce@news.free.fr>:
> 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.

Not lexical variables, by lexical variables containing strings.

> # 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'

Sorry, you have very little understanding of what happens there (as
most people do).  Do not call m().  You will still get high memory usage.
(Hint: constant folding at compile time.)

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

I do not think usemymalloc='n' is usable for anything but toy
examples.  Good rule is: do not expect your memory going back to
system in any real-life situation.

Hope this helps,
Ilya


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

Date: Mon, 20 Mar 2006 23:47:55 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: How to release memory ?
Message-Id: <rebnvd.02c.ln@teal.hjp.at>

Ilya Zakharevich wrote:
> <zdbrg@mail.con>], who wrote in article
> <441eae1f$0$13031$626a54ce@news.free.fr>:
>> Also, my perl is compiled with system malloc :
>> $ perl -V:usemymalloc
>> usemymalloc='n'
>> So it should release memory (for globals at least) ...
> 
> I do not think usemymalloc='n' is usable for anything but toy
> examples.

The perl-porters obviously disagree with you. usemymalloc='n' is the
default on Linux. It is also the way perl is built on at least two major
Linux distributions (Redhat and Debian).

        hp

-- 
   _  | Peter J. Holzer    | Löschung von at.usenet.schmankerl?
|_|_) | Sysadmin WSR/LUGA  | 
| |   | hjp@hjp.at         | Diskussion derzeit in at.usenet.gruppen
__/   | http://www.hjp.at/ |


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

Date: Mon, 20 Mar 2006 14:07:11 +0000 (UTC)
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: Perl IDE
Message-Id: <dvmcuf$rdq$1@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com>

Pengyang Lu wrote:
> 
> Does anybody know which Perl IDE software for UNIX should be used?
> 

perldoc -q ide


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

Date: Mon, 20 Mar 2006 15:30:00 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Perl IDE
Message-Id: <kjit12dv152kog0tiectr4gq2d8n2vsq08@4ax.com>

Pengyang Lu wrote:

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

No. There is no *should*.

-- 
	Bart.


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

Date: Mon, 20 Mar 2006 16:41:17 GMT
From: Baldoni <notanemail@no.com>
Subject: Re: Perl IDE
Message-Id: <NWATf.2637$hC.1151@trnddc08>

Pengyang Lu wrote:
> 
> Does anybody know which Perl IDE software for UNIX should be used?

I'm finding Bluefish is adequate.
http://bluefish.openoffice.nl/index.html

John


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

Date: Mon, 20 Mar 2006 22:19:35 +0100
From: Emmanuel Florac <eflorac@imaginet.fr>
Subject: Re: Perl IDE
Message-Id: <pan.2006.03.20.21.19.35.919070@imaginet.fr>

Le Mon, 20 Mar 2006 15:43:51 +0800, Pengyang Lu a écrit :

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

I use nedit (www.nedit.org) with a bunch of tools and macros I wrote
(you'll find most of them on www.nedit.org/niki ): 
-a "calltip file" that provides inline help; 
-code autocompletion; 
-a macro to call perldoc for the selected keyword or module;
-a set of macro for project management.

-- 
Le travail est la malédiction des classes qui boivent. 
O. Wilde.



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

Date: Mon, 20 Mar 2006 16:33:03 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: TCL vs. Perl
Message-Id: <dcFTf.2530$qX6.59652@news20.bellglobal.com>


<robic0> wrote in message news:no9s121ivruhnjc6pbou6jodofk1lnhdb0@4ax.com...

[proper attribution stripped by meathead and reinsterted]

> "Cameron Laird" <claird@lairds.us> wrote in message 
> news:1stqe3-t6k.ln1@lairds.us...
> > A.  good stylists use hashes and/or block-level
> >    assignment to $_ or the ternary operator
> >    to compose source that's arguably more
> >    powerful than any C-like switching.  Here's
> >    an example for the case at hand:
> >
> >        for ($myhash->{body}->{route}->{service}->{protocol}) {
> >     /smtp/ and do {...; last;};
> >     /ftp/  and do {...; last;};
> >     /http/ and do {...; last;};
> >        }
>
>
> My response to the above post didn't register.
> So I will try again via cut & past as a new message.
> Although I don't think the original title is relavent to the
> subject material, I did have issues with what Lisa Pearlson
> response. Hope this goes through.
>
> This code:
>
>        for ($myhash->{body}->{route}->{service}->{protocol}) {
>     /smtp/ and do {...; last;};
>     /ftp/  and do {...; last;};
>     /http/ and do {...; last;};
>        }
>
> Is no different than this code :
>
>        for ($myhash->{body}->{route}->{service}->{protocol})
>        {
>           if ($_ =~ /smtp)
>           {
>              ...;
>              goto END;
>           }

I see a huge difference. Cameron understands regular expression syntax; you 
don't.

And where did you get the "goto END" nonsense from? last is a control word 
to exit the loop; END is the last block called when your script exits. 
Please stop posting like you understand Perl yet.

Matt 




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

Date: 20 Mar 2006 21:45:51 GMT
From: <corff@zedat.fu-berlin.de>
Subject: Re: XML::Simple and utf8 woes
Message-Id: <488m4fFj3jadU2@uni-berlin.de>

corff@zedat.fu-berlin.de wrote:

: Really? I'll have to try tomorrow, don't have an XP box here right now.

I still don't have an XP system at hand.

If you run the code with the -CS flag given to perl, even the innocent
print statement in the middle of the code will output two characters
instead of one utf8-encoded character, and this doesn't change the broken
output of the XMLout() statement.

This is beyond any expectation created after reading the perlrun manpage.

However, if XML::Simple is instructed in the XMLout statement to escape
all non-ASCII characters, then, miraculuously, the correct utf8 replacements
appear. It really drives me nuts.

Oliver.
-- 
Dr. Oliver Corff              e-mail:    corff@zedat.fu-berlin.de


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

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


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