[29124] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 368 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 21 00:09:59 2007

Date: Fri, 20 Apr 2007 21:09:04 -0700 (PDT)
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, 20 Apr 2007     Volume: 11 Number: 368

Today's topics:
    Re: Booleans in Perl <dw149@acmex.gatech.edu>
    Re: Booleans in Perl <jurgenex@hotmail.com>
    Re: Booleans in Perl (aka ? the Platypus)
    Re: is laziness a programer's virtue? (aka ? the Platypus)
    Re: is laziness a programer's virtue? <ken@theoryyalgebra.com>
    Re: Lexical reference to an anonymous recursive subrout <mjcarman@mchsi.com>
    Re: Manipulate fields <noreply@invalid.net>
    Re: Manipulate fields <wahab-mail@gmx.de>
    Re: Manipulate fields <purlgurl@purlgurl.net>
    Re: Newbie queston on Perl and lex. somedeveloper@gmail.com
    Re: perldoc perllocal <1usa@llenroc.ude.invalid>
    Re: perldoc perllocal <spamtrap@dot-app.org>
    Re: perldoc perllocal <someone@example.com>
    Re: perldoc perllocal <pue@gmx.net>
    Re: Server For Rent? Where? <tadmc@augustmail.com>
    Re: Suppress warning <mritty@gmail.com>
        Syslog problem on Solaris 2.9 <ad_101@yahoo.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 20 Apr 2007 21:00:49 +0000 (UTC)
From: David Williams <dw149@acmex.gatech.edu>
Subject: Re: Booleans in Perl
Message-Id: <f0b9m1$67j$1@news-int.gatech.edu>


Busted :) 
I use php a lot and wrote echo instead of print.
I actually used print in my program.

So, what I get is that Perl does not really understand FALSE.

I guess my workaround is to use the eq operand.

Thanks everyone!

 
David Williams <dw149@acmex.gatech.edu> wrote:
> Small question.
> Why does PERL do the following

> $a=FALSE;
> $b=FALSE;
> $c=($a && $b); 
> if($c){
> echo "the expr evaluates to true";
> }
> else{
> echo "the expr evaluates to false;
> }

> I always get "the expr evaluates to true";

> if it is false && false, should it not be false?
> My workaround is to use the eq operand 
> -- 
> David Williams
> Georgia Institute of Technology, Atlanta Georgia, 30332
> Email: dw149@prism.gatech.edu

-- 
David Williams
Georgia Institute of Technology, Atlanta Georgia, 30332
Email: dw149@prism.gatech.edu


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

Date: Fri, 20 Apr 2007 21:50:06 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Booleans in Perl
Message-Id: <iAaWh.48$Rd.24@trndny08>

David Williams wrote:
>> $a=FALSE;
>> $b=FALSE;
>> $c=($a && $b);

> So, what I get is that Perl does not really understand FALSE.

Well, sort of. It's just a string without any special significance.

> I guess my workaround is to use the eq operand.

That's a poor workaround indeed.
Unfortunately you didn't tell us what your actual goal is. Perl offers a 
large variety of boolean interpretation of data, no matter if strings or 
numbers or even complex data structures, including functions to 
differentiate between undefined data and data that is defined but will 
evaluate to false.

One wild guess is that maybe you are using those values as flags to control 
the execution flow of your program. While there may be cases where this 
actually simplifies the code, in general it often indicates a not so optimal 
design of the algorithm. Trying to police your code by using flags is about 
as evil as goto's.

Also, where does that value 'FALSE' on the right side come from? In my 
experience it is very, very rare that you are assigning a static boolean 
value to a variable. Much more common is the case were an expression 
determines the logical value.

Typical beginner's code:

    if (errorcheck($input) == true) {
        return false;
      } else {
        return true;
      }

Once you explain that this can better be written as

    return !errorcheck($input)

then the whole idea of using literal boolean values becomes a lot less 
appealing.

jue 




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

Date: Sat, 21 Apr 2007 01:13:40 GMT
From: "David Formosa (aka ? the Platypus)" <dformosa@usyd.edu.au>
Subject: Re: Booleans in Perl
Message-Id: <slrnf2ipsu.o5h.dformosa@localhost.localdomain>

On Fri, 20 Apr 2007 21:00:49 +0000 (UTC), David Williams
<dw149@acmex.gatech.edu> wrote:

[...]

> So, what I get is that Perl does not really understand FALSE.

Perl has a very simple model of the booleans, false is 0,'0' and '',
everything else is true.



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

Date: Sat, 21 Apr 2007 01:29:15 GMT
From: "David Formosa (aka ? the Platypus)" <dformosa@usyd.edu.au>
Subject: Re: is laziness a programer's virtue?
Message-Id: <slrnf2iqq5.o5h.dformosa@localhost.localdomain>

On Sun, 15 Apr 2007 22:53:28 -0500, Dan Bensen
<randomgeek@cyberspace.net> wrote:
[...]
> Ken Tilton wrote:
[...]
>>> When the sorcerer Larry Wall said ?The three chief virtues of a
>>> programmer are: Laziness, Impatience and Hubris?, he used the word
>>> ?laziness? to loosely imply ?natural disposition that results in being
>>> economic?. As you can see now, ?Resistant to work or exertion? is
>>> clearly not positive and not a virtue, 
>
> Actually, I disagree with this assertion.  The gung-ho kind of person
> who revels in brute effort often won't even think of good programming
> ideas because he|she is so intent on solving the problem through sheer
> force, and also derives a sense of pride from that.

The "Worse is better" school of thought argues that this is a
legitimate way to solve problems.  Indeed there is the Ken Thompson
quote "When in doubt, use brute force".  

[...]

>  It's laziness that inspires the programmer to write more and
> more abstract code.  The only thing that Larry is *not* referring to is
> intellectual laziness.

Exactly.



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

Date: Fri, 20 Apr 2007 22:16:42 -0400
From: Ken Tilton <ken@theoryyalgebra.com>
Subject: Re: is laziness a programer's virtue?
Message-Id: <iueWh.7442$RG4.1332@newsfe12.lga>



David Formosa (aka ? the Platypus) wrote:
> On Sun, 15 Apr 2007 22:53:28 -0500, Dan Bensen
> <randomgeek@cyberspace.net> wrote:
> [...]
> 
>>Ken Tilton wrote:
> 
> [...]
> 
>>>>When the sorcerer Larry Wall said ?The three chief virtues of a
>>>>programmer are: Laziness, Impatience and Hubris?, he used the word
>>>>?laziness? to loosely imply ?natural disposition that results in being
>>>>economic?. As you can see now, ?Resistant to work or exertion? is
>>>>clearly not positive and not a virtue, 
>>
>>Actually, I disagree with this assertion.  The gung-ho kind of person
>>who revels in brute effort often won't even think of good programming
>>ideas because he|she is so intent on solving the problem through sheer
>>force, and also derives a sense of pride from that.
> 
> 
> The "Worse is better" school of thought argues that this is a
> legitimate way to solve problems.

Wow, where do you get that?!

> The concept known as "worse is better" holds that in software making
> (and perhaps in other arenas as well) it is better to start with a
> minimal creation and grow it as needed.
> http://www.dreamsongs.com/WorseIsBetter.html

That's about "when to go live", not "how to program".

kt

-- 
http://www.theoryyalgebra.com/

"Algebra is the metaphysics of arithmetic." - John Ray

"As long as algebra is taught in school,
there will be prayer in school." - Cokie Roberts

"Stand firm in your refusal to remain conscious during algebra."
    - Fran Lebowitz

"I'm an algebra liar. I figure two good lies make a positive."
    - Tim Allen



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

Date: Fri, 20 Apr 2007 23:39:28 GMT
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: Lexical reference to an anonymous recursive subroutine: impossible?
Message-Id: <QacWh.67377$_c5.56625@attbi_s22>

On 4/19/2007 5:25 PM, florian wrote:
> 
> I know I could have achieved a comparable effect by using an ordinary
> subroutine, using Exporter and disallowing to export the subroutine, which
> would have restricted it to the module file

Just to be clear, Perl doesn't have a concept of "private" functions like some
other languages do. An unexported subroutine can still be called using a fully
qualified name (e.g. Foo::Bar::baz()).

For any lurking novices out there, I'd also like to point out that in Perl it's
customary to expect the users of your module to play nice and not call
undocumented functions. Sometimes people prefix sub names with an underscore
(e.g. _mysub) to provide an extra indication that a sub is intended to be
private. While forcibly preventing bad behavior is an interesting exercise, it's
rare for people to actually do so.

-mjc


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

Date: Fri, 20 Apr 2007 13:59:45 -0700
From: Ala Qumsieh <noreply@invalid.net>
Subject: Re: Manipulate fields
Message-Id: <6R9Wh.1079$ns5.938@newssvr17.news.prodigy.net>

Purl Gurl wrote:

> 
> #!perl
> 
> $input = "199.67.218.64,26,199.67.218.76,199.67.218.77";
> 
> $input =~ s/,(\d+),/,2 ** $1,/;
> 
> print $input;
> 
> print "\n\n";
> 
> $input = "199.67.218.64,26,199.67.218.76,199.67.218.77";
> 
> if ($input =~ /,(\d+),/)
>   {
>    $new = 2 ** $1;
>    $input =~ s/,(\d+),/,$new,/;
>   }
> 
> print $input;

or more succinctly:

  $input =~ s/(?<=,)(\d+)(?=,)/2 ** $1/e;

--Ala



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

Date: Fri, 20 Apr 2007 23:21:05 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Manipulate fields
Message-Id: <f0bh99$h3i$1@mlucom4.urz.uni-halle.de>

Ala Qumsieh wrote:
> Purl Gurl wrote:
>> if ($input =~ /,(\d+),/)
>>   {
>>    $new = 2 ** $1;
>>    $input =~ s/,(\d+),/,$new,/;
>>   }
>>
>> print $input;
> 
> or more succinctly:
> 
>   $input =~ s/(?<=,)(\d+)(?=,)/2 ** $1/e;

Nice Idea, that would give "a whole"
program like:

   ...
   s/\b([\w\.]+)\b/fmt $1/eg and print while <DATA>;
   ...


Where the 'fmt' function would, depending
on the format needed, look like:

   ...
   sub fmt { ($_=shift)=~/\./ ? unpack "H*",inet_aton $_ : sprintf "0x%08X",2**$_ }
   ...

The above would print the following output
(if the data provided by the OP is below __DATA__)

    c743da40,0x04000000,c743da4c,c743da4d
    c743ece0,0x10000000,c743ece1,
    c743ecf0,0x10000000,c743ecf1,


For the OP: the 'prologue' needed for this
'program' would be:

    use strict;
    use warnings;
    use Socket;
    ...


Regards

M.


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

Date: Fri, 20 Apr 2007 16:59:09 -0700
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: Manipulate fields
Message-Id: <t76dnfMCVJNLzrTbnZ2dnUVZ_hKdnZ2d@giganews.com>

Ala Qumsieh wrote:

> Purl Gurl wrote:

(snipped confusion on the part of Ala Qumsieh)

You have responded to the wrong person. I did not
present a question to this group. You should be
responding to the author who did ask a question.

The original author is "Sashi" for your reference
and assistance in finding his article for response.

Purl Gurl


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

Date: 20 Apr 2007 18:57:02 -0700
From: somedeveloper@gmail.com
Subject: Re: Newbie queston on Perl and lex.
Message-Id: <1177120622.499573.12410@p77g2000hsh.googlegroups.com>

On Apr 20, 3:35 pm, Michele Dondi <bik.m...@tiscalinet.it> wrote:
> On 19 Apr 2007 23:01:54 -0700, somedevelo...@gmail.com wrote:
>
> >1. If my needs are only lexical scanning (and not compiler- and
> >interpretor-writing), and
> >2. If I'm proficient in Perl and Perl regular expressions,
>
> >would I ever need to learn a tool such as f/lex?  Is there anything
> >that Perl REs cannot do easily/elegantly which f/lex can, for example?
>
> I don't have the slightest idea. But I know an article that you may be
> interested in:
>
> http://www.perl.com/pub/a/2006/01/05/parsing.html
>
> Michele
> --
> {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
> (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
> .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
> 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

Michele, thanks! The article did give me an idea of what I guess I was
trying to know.

PS: Ran your signature program... it's cool! Hopefully, I'll be able
to decode it in near future... when I'm more comfortable with the
language.



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

Date: Fri, 20 Apr 2007 18:48:01 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: perldoc perllocal
Message-Id: <Xns9918969195369asu1cornelledu@127.0.0.1>

Martin Kißner <news@chaos-net.de> wrote in 
news:slrnf2ho95.lf.news@maki.homeunix.net:

> Hello together,
> 
> with "perldoc perllocal" I can get some Information about modules I
> installed myself.
> 
> My question:
> Where is this information usually stored (which file or so)?
> 
> I have Mac OS X 10.4.
> If anybody knows, I'd be interested if there is something special about
> where this info is stored.

The file is perllocal.pod. I am sure OS X has a file search utility.

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://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



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

Date: Fri, 20 Apr 2007 14:55:23 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: perldoc perllocal
Message-Id: <m23b2uanac.fsf@local.wv-www.com>

Martin Kißner <news@chaos-net.de> writes:

> with "perldoc perllocal" I can get some Information about modules I
> installed myself.
>
> My question:
> Where is this information usually stored (which file or so)?

Why do you need to know? Seriously - I suspect an A/B problem, where your
actual task A is getting information about currently-installed modules,
and you've decided that parsing perllocal.pod is how to do that, so you're
asking question B - where is that file.

The thing about an A/B problem is that B is not necessarily the best way
to solve A; i.e. in this case, there may be a better way to get the info
you need than trying to parse perllocal.pod. So that's why I'm asking you,
what is it you're hoping to do? What's task A?

> If anybody knows, I'd be interested if there is something special about
> where this info is stored.

One thing special about it is that, while it has information about user-
installed modules, it's stored in the directory normally reserved for core
modules. In your case, assuming you're using the Perl that Apple shipped
with the OS:

    /System/Library/Perl/5.8.6/darwin-thread-multi-2level/perllocal.pod

There's nothing at all magical about that file. It's just a standard POD
formatted text file. When you install a module, the installation process
simply appends a new entry.

There's nothing especially smart about the process of updating perllocal;
the new text is just blindly appended, without looking for or deleting
older entries for the same module.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Fri, 20 Apr 2007 19:17:36 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: perldoc perllocal
Message-Id: <kl8Wh.22640$GV5.10016@edtnps89>

Martin Kißner wrote:
> Hello together,
> 
> with "perldoc perllocal" I can get some Information about modules I
> installed myself.
> 
> My question:
> Where is this information usually stored (which file or so)?

perldoc -l perllocal



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


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

Date: Fri, 20 Apr 2007 21:25:01 +0200
From: =?ISO-8859-1?Q?Andreas_P=FCrzer?= <pue@gmx.net>
Subject: Re: perldoc perllocal
Message-Id: <58si9uF2ikf0sU1@mid.individual.net>

A. Sinan Unur schrieb:
> Martin Kißner <news@chaos-net.de> wrote in 
> news:slrnf2ho95.lf.news@maki.homeunix.net:
> 
> 
>>Hello together,
>>
>>with "perldoc perllocal" I can get some Information about modules I
>>installed myself.
>>
>>My question:
>>Where is this information usually stored (which file or so)?
>>
> 
> 
> The file is perllocal.pod. I am sure OS X has a file search utility.

Just let perldoc tell you:

`perldoc -l perllocal`

> 
> Sinan 

Andreas Pürzer

-- 
Have Fun,
and if you can't have fun,
have someone else's fun.
		The Beautiful South


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

Date: Fri, 20 Apr 2007 19:47:42 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Server For Rent? Where?
Message-Id: <slrnf2inpe.iau.tadmc@tadmc30.august.net>

skieros <nikos1337@gmail.com> wrote:


> Not all of the people here are anti-social dorks like you are.


The people here like to discuss Perl.

You are the one starting a thread completely devoid of any
connection with Perl.

Who is the anti-social one again?


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


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

Date: 20 Apr 2007 13:40:56 -0700
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Suppress warning
Message-Id: <1177101655.942326.21890@n59g2000hsh.googlegroups.com>

On Apr 20, 10:53 am, Ian Wilson <scoblo...@infotop.co.uk> wrote:
> When I run the code below I get an unwanted warning and the expected result.
>
>  > soapclientauto.pl
> Use of inherited AUTOLOAD for non-method main::c2f() is deprecated at
> soapclientauto.pl line 11.
> 41.1C = 105.98F.
>
> ------------------------------------------------------
> #!perl
> use strict;
> use warnings;
>
> use SOAP::Lite +autodispatch =>
>    uri => 'http://www.example.com/Temperature',
>    proxy => 'http://localhost/cgi-bin/soapservice.pl';
>
> {
>    no warnings 'deprecated';
>    print "41.1C = ", c2f(41.1), "F.\n";}
>
> ------------------------------------------------------
> ActiveState Perl 5.8.8 on XP
>
> The warning arises when I use SOAP::Lite's "autodispatch" feature.
>
> `no warnings;` suppresses the warning but seems overkill.
>
> Is there a way to identify the category of warning so I can suppress it
> more selectively?
>
> Is there another way to avoid whatever the warning is warning me of
> (which I don't understand) - assuming I don't want to tinker with
> SOAP::Lite?

All of Perl's warnings and errors are well documented in `perldoc
perldiag`:

     Use of inherited AUTOLOAD for non-method %s() is deprecated
         (D deprecated) As an (ahem) accidental feature,
         "AUTOLOAD" subroutines are looked up as methods (using
         the @ISA hierarchy) even when the subroutines to be
         autoloaded were called as plain functions (e.g.
         "Foo::bar()"), not as methods (e.g. "Foo->bar()" or
         "$obj->bar()").

         This bug will be rectified in future by using method
         lookup only for methods' "AUTOLOAD"s.  However, there is
         a significant base of existing code that may be using
         the old behavior.  So, as an interim step, Perl
         currently issues an optional warning when non-methods
         use inherited "AUTOLOAD"s.

         The simple rule is:  Inheritance will not work when
         autoloading non-methods.  The simple fix for old code
         is:  In any module that used to depend on inheriting
         "AUTOLOAD" for non-methods from a base class named
         "BaseClass", execute "*AUTOLOAD = \&BaseClass::AUTOLOAD"
         during startup.

         In code that currently says "use AutoLoader; @ISA =
         qw(AutoLoader);" you should remove AutoLoader from @ISA
         and change "use AutoLoader;" to "use AutoLoader
         'AUTOLOAD';".






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

Date: 20 Apr 2007 15:01:56 -0700
From: A <ad_101@yahoo.com>
Subject: Syslog problem on Solaris 2.9
Message-Id: <1177106516.112063.144070@e65g2000hsc.googlegroups.com>

I'm using Sys::Syslog but nothing is being written to the logs.

I'd appreciate your help on this.

This is on Solaris 2.9 on SPARC.

File /etc/syslog.conf contains
    local1.info   /var/log/mylog

Here's the test script.

#+++++++++++++++++++++
#!/usr/local/bin/perl

use Sys::Syslog;
use diagnostics;
use strict;

my $r;

$r = &Sys::Syslog::openlog("$0 $$", "ndelay,pid", "local1");
print STDERR "$$: openlog returned $r\n";

$r = &Sys::Syslog::syslog("info", "Test of info to local1");
print STDERR "$$: syslog returned $r\n";

$r = &Sys::Syslog::closelog();
print STDERR "$$: closelog returned $r\n";

print STDERR "$$: $0: End\n";
#---------------------------------

When I run it, I get:

$ testsyslog
6491: openlog returned Sys::Syslog::SYSLOG
6491: syslog returned 1
6491: closelog returned 1
6491: testsyslog: End

but nothing is printed to /var/log/mylog, while if I run

$ logger -p "local1.info" -t "from_logger $$" "Test1_logger"

then the following line is added to /var/log/mylog:

Apr 20 16:59:09 myhost from_logger 14256: [ID 702911 local1.info]
Test1_logger

I also tried adding (on Perl 5.8.8)

$r = &Sys::Syslog::setlogsock('stream', '/dev/conslog');
print STDERR "$$: setlogsock returned $r\n";

above the openlog() but that doesn't change the symptom.

The machine has two versions of Perl installed, Perl 5.6.1 which came
with Solaris and Perl 5.8.8 with threads. The behaviour is same with
both versions of Perl.

What am I doing wrong?

Thanks.



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

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 V11 Issue 368
**************************************


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