[31508] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2767 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 14 18:09:43 2010

Date: Thu, 14 Jan 2010 15:09:08 -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           Thu, 14 Jan 2010     Volume: 11 Number: 2767

Today's topics:
        'use' changed to 'require' <john1949@yahoo.com>
    Re: 'use' changed to 'require' <jurgenex@hotmail.com>
    Re: 'use' changed to 'require' <john1949@yahoo.com>
    Re: 'use' changed to 'require' <jurgenex@hotmail.com>
    Re: 'use' changed to 'require' <uri@StemSystems.com>
    Re: 'use' changed to 'require' <spamtrap@shermpendley.com>
    Re: 'use' changed to 'require' <paduille.4061.mumia.w+nospam@earthlink.net>
        a defense of ad hoc software development <cartercc@gmail.com>
    Re: a defense of ad hoc software development <marc.girod@gmail.com>
    Re: a defense of ad hoc software development <cho.seung-hui@vt.edu>
    Re: a defense of ad hoc software development <daniel.eliason@excite.com>
    Re: converting from 'use' to 'require' <bugbear@trim_papermule.co.uk_trim>
    Re: converting from 'use' to 'require' <OJZGSRPBZVCX@spammotel.com>
    Re: FAQ 9.1 What is the correct form of response from a <marc.girod@gmail.com>
    Re: perl compiler to exe <robin1@cnsp.com>
        Perl module to display MIME email in browser? <news@lawshouse.org>
    Re: some perl programs I wrote <uri@StemSystems.com>
    Re: some perl programs I wrote <ralph.malph@altavista.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 14 Jan 2010 13:46:33 -0000
From: "John" <john1949@yahoo.com>
Subject: 'use' changed to 'require'
Message-Id: <hin77q$k6t$1@news.albasani.net>

Hi

I've changed
use Socket;
to
require Socket;

in a subroutine since I use it infrequently

I'm getting the error message

Bareword "AF_INET" not allowed while "strict subs"

What have I done?

Regards
John




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

Date: Thu, 14 Jan 2010 06:04:42 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: 'use' changed to 'require'
Message-Id: <1v8uk51i808hfbe9f7h9atf577fa98eokn@4ax.com>

"John" <john1949@yahoo.com> wrote:
>I've changed
>use Socket;
>to
>require Socket;
>
>in a subroutine since I use it infrequently
>
>I'm getting the error message
>
>Bareword "AF_INET" not allowed while "strict subs"
>
>What have I done?

Isn't that obvious? You changed 
	use Socket;
to
	require Socket;
;-))

Seriously, you are missing the import() part of use(), see 
	perldoc -f use

jue 


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

Date: Thu, 14 Jan 2010 14:25:29 -0000
From: "John" <john1949@yahoo.com>
Subject: Re: 'use' changed to 'require'
Message-Id: <hin9gp$nuq$1@news.albasani.net>


"Jürgen Exner" <jurgenex@hotmail.com> wrote in message 
news:1v8uk51i808hfbe9f7h9atf577fa98eokn@4ax.com...
> "John" <john1949@yahoo.com> wrote:
>>I've changed
>>use Socket;
>>to
>>require Socket;
>>
>>in a subroutine since I use it infrequently
>>
>>I'm getting the error message
>>
>>Bareword "AF_INET" not allowed while "strict subs"
>>
>>What have I done?
>
> Isn't that obvious? You changed
> use Socket;
> to
> require Socket;
> ;-))
>
> Seriously, you are missing the import() part of use(), see
> perldoc -f use
>
> jue

I've added Socket->import(); but same error - John





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

Date: Thu, 14 Jan 2010 06:36:20 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: 'use' changed to 'require'
Message-Id: <3hauk5hp5eq0o3tlhv2d94ol4a8tureubp@4ax.com>

"John" <john1949@yahoo.com> wrote:
>"Jürgen Exner" <jurgenex@hotmail.com> wrote in message 
>> "John" <john1949@yahoo.com> wrote:
>>>I've changed
>>>use Socket;
>>>to
>>>require Socket;
>>>
>>>in a subroutine since I use it infrequently
>>>
>>>I'm getting the error message
>>>
>>>Bareword "AF_INET" not allowed while "strict subs"
>>>
>>>What have I done?
>>
>> Isn't that obvious? You changed
>> use Socket;
>> to
>> require Socket;
>> ;-))
>>
>> Seriously, you are missing the import() part of use(), see
>> perldoc -f use
>
>I've added Socket->import(); but same error - John

Oh, yeah, of course, sorry. The "Bareword ..." message is a compile time
error while the require/import would be done at run time, i.e. way
later.

Not sure what to do about it, I'm not familiar with Socket or what
AF_INET is. I guess maybe you could use a fully qualified name. 

jue


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

Date: Thu, 14 Jan 2010 09:42:20 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: 'use' changed to 'require'
Message-Id: <87k4vklpdf.fsf@quad.sysarch.com>

>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:

  JE> "John" <john1949@yahoo.com> wrote:

  >> I've added Socket->import(); but same error - John

  JE> Oh, yeah, of course, sorry. The "Bareword ..." message is a compile time
  JE> error while the require/import would be done at run time, i.e. way
  JE> later.

  JE> Not sure what to do about it, I'm not familiar with Socket or what
  JE> AF_INET is. I guess maybe you could use a fully qualified name. 

AF_INET is a constant that shouldn't be needed in common socket
code. he should be using IO::Socket instead which has a better API and
less need of obscure constants.

the OP should post the whole section of code with the socket stuff. and
if he does need it, he can't do require and even import since the import
has to be done at compile time for the constant to be declare properly
and then parsed that way in his code. putting the import into a BEGIN
would only help if the module were also loaded there but that becomes
use again.

another solution is to move all the code that involves the socket stuff
to its own module, call use Socket in there, and load his module on
demand.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Thu, 14 Jan 2010 10:41:59 -0500
From: Sherm Pendley <spamtrap@shermpendley.com>
Subject: Re: 'use' changed to 'require'
Message-Id: <m26374ae2g.fsf@shermpendley.com>

"John" <john1949@yahoo.com> writes:

> I've changed
> use Socket;
> to
> require Socket;
>
> in a subroutine since I use it infrequently
>
> I'm getting the error message
>
> Bareword "AF_INET" not allowed while "strict subs"
>
> What have I done?

You changed "use" to "require". They don't do the same thing; more to
the point, the latter does not call "import," which is why the AF_INET
symbol didn't get imported into your name space.

For details, have a look at the docs for the functions you're using:

    perldoc -f use
    perldoc -f require

sherm--


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

Date: Thu, 14 Jan 2010 09:32:08 -0600
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: 'use' changed to 'require'
Message-Id: <7bydncmlKpVL6dLWnZ2dnUVZ_t-dnZ2d@earthlink.com>

On 01/14/2010 08:25 AM, John wrote:
> "Jürgen Exner" <jurgenex@hotmail.com> wrote in message 
> news:1v8uk51i808hfbe9f7h9atf577fa98eokn@4ax.com...
>> "John" <john1949@yahoo.com> wrote:
>>> I've changed
>>> use Socket;
>>> to
>>> require Socket;
>>>
>>> in a subroutine since I use it infrequently
>>>
>>> I'm getting the error message
>>>
>>> Bareword "AF_INET" not allowed while "strict subs"
>>>
>>> What have I done?
>> Isn't that obvious? You changed
>> use Socket;
>> to
>> require Socket;
>> ;-))
>>
>> Seriously, you are missing the import() part of use(), see
>> perldoc -f use
>>
>> jue
> 
> I've added Socket->import(); but same error - John
> 
> 
> 

Treat AF_INET as a function--which it is: AF_INET().

Or you can place a forward declaration near the top of your program:

sub AF_INET;




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

Date: Thu, 14 Jan 2010 06:46:02 -0800 (PST)
From: ccc31807 <cartercc@gmail.com>
Subject: a defense of ad hoc software development
Message-Id: <33f25714-57f9-42ec-9e60-092b6fb3ae01@21g2000yqj.googlegroups.com>

On page 229 of Paul Graham's 'ANSI Common Lisp' he writes:

 <quote>
     If programming were an entirely mechanical process -- a matter of
simply translating specifications into code -- it would be reasonable
to do everything in a single step. But programming is never like that.
No matter how precise the specifications, programming always involves
a certain amount of exploration -- usually a lot more than anyone had
anticipated.
     It might seem that if the specifications wee good, programming
would simply be a matter of translating them into code. This is a
widespread misconception. Programming necessarily involves
exploration, because specifications are necessarily vague. If they
weren't vague, they wouldn't be specifications.
     In other fields, it may be desirable for specifications to be as
precise as possible. If you're asking for a piece of metal to be cut
into a certain shape, it's probably best to say exactly what you want.
But this rule does not extend to software, because programs and
specifications are made out of the same thing: text. You can't write
specifications that say exactly what you want. If the specification
were that precise, then they would be the program.
</quote>

In a footnote, Graham writes:

<quote>
     The difference between specifications and programs is a
difference in degree, not a difference in kind. Once we realize this,
it seems strange to require that one write specifications for a
program before beginning to implement it. If the program has to be
written in a low-level language, then it would be reasonable to
require that it be described in high-level terms first. But as the
programming language becomes more abstract, the need for
specifications begins to evaporate. Or rather, the implementation and
the specifications can become the same thing.
     If the high-level language is going to be re-implemented in a
lower-level language, it starts to look even more like specifications.
What Section 13l.7 is saying, in other words, is that the
specifications for C programs could be written in Lisp.
</quote>

In my SwE classes, we spent a lot of time looking at process and
processes, including MIL STD 498 and IEEE Std 830-1984, etc. My
professors were both ex-military, one who spent his career in the USAF
developing software and writing Ada, and both were firmly in the
'heavy' camp (as opposed to the lightweight/agile camp).

In my own job, which requires writing software for lay users, all I
ever get is abbreviated English language requests, and I have learned
better than to ask users for their requirements because they have no
idea what requirements are. (As a joke, I have sent a couple a copy of
IEEE Std 830-1984 and told them that I needed something like that, but
the joke went over like a lead balloon -- not funny at all.) Of
necessity I have learned to expect to write a number of versions of
the same script before the user accepts it.

I understand that Graham isn't talking about requirements, and to many
people specifications and requirements amount to the same thing. I
also understand the necessity for planning. However, the Graham quote
seems to me a reasonable articulation for ad hoc development. (It's
something I wanted to say to jue in particular but couldn't find the
words.)

Comments?

CC


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

Date: Thu, 14 Jan 2010 09:54:02 -0800 (PST)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: a defense of ad hoc software development
Message-Id: <0b392092-5699-47d6-a7a6-5d7344905b70@j4g2000yqe.googlegroups.com>

On Jan 14, 2:46=A0pm, ccc31807 <carte...@gmail.com> wrote:

> Comments?

Paul Graham is a genious. He speaks Gold.
I loved his book /On LISP/.
Planning is useful, but plans are worthless.

Marc


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

Date: Thu, 14 Jan 2010 15:30:01 -0500
From: Richard McBeef <cho.seung-hui@vt.edu>
Subject: Re: a defense of ad hoc software development
Message-Id: <hinusa$bt$1@speranza.aioe.org>

ccc31807 wrote:
[snip]
> Comments?
Yeah, Paul Graham is a total b.s. artist.
Besides a prolific author of internet screeds
he wrote some successful software a long time ago.
Oh, and I do not deny he is a lisp expert.
But, yeah, PG is full of shit and his bazillion
bullshit essays all have the same annoying
common theme "I'm the best! Be like me!".


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

Date: Thu, 14 Jan 2010 14:29:33 -0800 (PST)
From: fortunatus <daniel.eliason@excite.com>
Subject: Re: a defense of ad hoc software development
Message-Id: <c3f47362-4a53-4d41-ad4e-ea9d07cef78f@21g2000yqj.googlegroups.com>

On Jan 14, 9:46=A0am, ccc31807 <carte...@gmail.com> wrote:
> In my own job, which requires writing software for lay users, all I
> ever get is abbreviated English language requests, and I have learned
> better than to ask users for their requirements because they have no
> idea what requirements are.

Nobody expects non-programmers to be able to generate programmers's
requirements.

Programmers generate requirements for themselves based on less formal
Q&A with the customer.

No matter what, a programmer works to specific requirements that are
supposed to match the user's expectations and/or needs.  The
requirements might be in the programmer's head, and they might be
developed by evolutionary process throughout the code writing, but
they exist.  If there is more than one programmer on a team then there
is a need to codify requirements into documents to some degree.

I think it is not feasible to say that requriements can be so detailed
as to be directly executable.  In teamwork it is useful to communicate
when there remains a large degree of ambiguity, and allow team members
to contribute to resolutions.

So you can use Lisp to capture/express requirements, but it won't be a
complete solution to the problem before you break the work up among
team members.  Yet at that stage it would normally be named a
requirements document.

My point is that the work needs to be broken up and distributed among
team members before ambiguity is resolved.  At that point there should
be some requirements written down for team members to start working
from.  Therefore the requirements, at that stage, even if captured in
Lisp or other executable format, /must/ have too many holes to really
solve the whole problem, or else the team is not dividing the workload
effectively.


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

Date: Thu, 14 Jan 2010 15:02:39 +0000
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: converting from 'use' to 'require'
Message-Id: <MeWdnZZardiNr9LWnZ2dnUVZ8lRi4p2d@brightview.co.uk>

Shmuel (Seymour J.) Metz wrote:
> In <VsmdnQX2_MhYkNvWnZ2dnUVZ8o1i4p2d@brightview.co.uk>, on 01/07/2010
>    at 04:37 PM, bugbear <bugbear@trim_papermule.co.uk_trim> said:
> 
>> How does changing from "use" to "require" speed anything up
>> (unless import is a lot slower than I thought)
> 
> By using eval inside of an if you can cause the require to be
> conditionally executed.

Oh, I see. I do that all the time.

I thought you meant *only* changing use to require :-(

   BugBear


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

Date: Thu, 14 Jan 2010 20:21:07 +0100
From: "Jochen Lehmeier" <OJZGSRPBZVCX@spammotel.com>
Subject: Re: converting from 'use' to 'require'
Message-Id: <op.u6jephrjmk9oye@frodo>

On Thu, 14 Jan 2010 16:02:39 +0100, bugbear  
<bugbear@trim_papermule.co.uk_trim> wrote:

> Shmuel (Seymour J.) Metz wrote:
>> In <VsmdnQX2_MhYkNvWnZ2dnUVZ8o1i4p2d@brightview.co.uk>, on 01/07/2010
>>    at 04:37 PM, bugbear <bugbear@trim_papermule.co.uk_trim> said:
>>
>>> How does changing from "use" to "require" speed anything up
>>> (unless import is a lot slower than I thought)
>>  By using eval inside of an if you can cause the require to be
>> conditionally executed.
>
> Oh, I see. I do that all the time.
> I thought you meant *only* changing use to require :-(

You do not need an eval with require to make it conditional. require is  
not executed at compile time. See:

~> perl -e 'use XYZZY;'
Can't locate XYZZY.pm in @INC (@INC contains: /etc/perl  
/usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5  
/usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8  
/usr/local/lib/site_perl .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
~> perl -e 'require XYZZY;'
Can't locate XYZZY.pm in @INC (@INC contains: /etc/perl  
/usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5  
/usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8  
/usr/local/lib/site_perl .) at -e line 1.
bilbo:~# perl -e 'require XYZZY if 0; print "OK\n";'
OK


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

Date: Thu, 14 Jan 2010 09:46:31 -0800 (PST)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: FAQ 9.1 What is the correct form of response from a CGI script?
Message-Id: <17f16443-42a2-4fed-8daa-8c9dca7641f5@c34g2000yqn.googlegroups.com>

On Jan 14, 5:00=A0pm, PerlFAQ Server <br...@theperlreview.com> wrote:

> It is not
> specific to Perl, and has its own FAQs and tutorials, and usenet group,
> comp.infosystems.www.authoring.cgi

I had a look, and it is not very promising...
There is one message dated Jan 10, and it is about finding a new
moderator.
The previous message is dated Oct 18 2008

Marc


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

Date: Thu, 14 Jan 2010 09:53:02 -0800 (PST)
From: Robin <robin1@cnsp.com>
Subject: Re: perl compiler to exe
Message-Id: <30b07a7e-f724-48ba-aa4b-e9dd7a63bcb9@c3g2000yqd.googlegroups.com>



Ben Morrow wrote:
> Quoth Robin <robin1@cnsp.com>:
> > Does anyone know of a good program I can use to change perl programs
> > to exe's that is free. I know there is  the activestate one is good,
> > but too expensive.
>
> pp, part of PAR::Packer.
>
> Ben

Thanks, I will look into it.
-Robin


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

Date: Thu, 14 Jan 2010 22:08:29 +0000
From: Henry Law <news@lawshouse.org>
Subject: Perl module to display MIME email in browser?
Message-Id: <to6dna1a6u9GCNLWnZ2dnUVZ8nadnZ2d@giganews.com>

I have a database into which will go archived emails; the plan is then 
to have Perl CGI programs which will query the database and on request 
display the email.  Some of the emails are in MIME format and I'm in 
need of some code which will understand the MIME tree and generate the 
relevant HTML and images so that the email can be read in its original 
form.  In other words, the display part of a web mail application.

I have Email::Simple and its friends installed and can see how I'd write 
this code myself, but I'm not particularly familiar with MIME, or with 
working out which part to use and so on.  I'm hoping there's a module or 
some sample code which will help me, but I've been unable to structure a 
suitable query which will pick it out of the host of very similar 
textual references to full webmail clients and to basic MIME-extraction 
modules such as Email::MIME which I already know how to use.

Anyone done this, or something similar, who could point me in the right 
direction?  Otherwise it's more heroic coding at dead of night ...

-- 

Henry Law            Manchester, England


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

Date: Thu, 14 Jan 2010 09:25:14 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: some perl programs I wrote
Message-Id: <87k4vkn4qd.fsf@quad.sysarch.com>

>>>>> "PJH" == Peter J Holzer <hjp-usenet2@hjp.at> writes:

  PJH> On 2010-01-14 09:31, Uri Guttman <uri@StemSystems.com> wrote:
  >>>>>>> "R" == Robin  <robin1@cnsp.com> writes:
  >> 
  R> check out some of my perl programs,
  R> http://offlame.memebot.com
  >> 
  >> you have a lot of perl and programming to learn still.
  PJH> [...]
  >> $_ = "$q" / "$m"; 
  >> 
  >> that is horrible in so many ways. why did you put "" around the
  >> variables? especially since you then do a math operation on them. why
  >> did you assign the result to $_ instead of a named variable? 
  >> 
  >> if ($_ !~ /\./) {  
  >> 
  >> did you know you could use named variables with the !~ operator? and
  >> checking if a number has a fractional part with a regex is very
  >> clunky. it is better to stick to pure math ops like int(), * and /.

  PJH> And especially %.

somehow i forgot that one. it was very late and i was in shock from
reading that code. i seem to recall the OP posted this before as i seem
to have a link to one of its programs in my browser history. this does
not bode well as i bet it never took the previous feedback. 

i should use it as a test to see what perl people know. a client of mine
does that, he sends out a sub about 20 lines long and asks the candidate
to give edits and feedback on making it better. it has many ways to be
improved. interested idea and much better than any multiple choice
tests. it gets into your true coding skills to see ways to write better
code.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Thu, 14 Jan 2010 16:30:59 -0500
From: Ralph Malph <ralph.malph@altavista.com>
Subject: Re: some perl programs I wrote
Message-Id: <hio2ei$63j$1@speranza.aioe.org>

Uri Guttman wrote:
>>>>>> "R" == Robin  <robin1@cnsp.com> writes:
> 
>   R> check out some of my perl programs,
>   R> http://offlame.memebot.com
> 
> you have a lot of perl and programming to learn still.
No, the OP needs to stop making some silly mistakes
but he is clearly a quite capable programmer.
You point out nothing but trivial things such as 
unused variables
and act like a drama queen using words like
"horrible" to describe these things.

To the OP: there is a saying that bike sheds are
harder to make than nuclear power plants.
http://www.freebsd.org/doc/en_US.ISO8859-1/books/faq/misc.html#BIKESHED-PAINTING
Online you will find unemployed and jaded losers
willing to pick apart trivial details but not help
you with anything of significance.
Please, don't frustrate yourself looking for their
approval for it does not exist in their miserable
lives.
Trust me, it is quite telling that you only
received comments on one of your smaller works
listed on the (shorter) second page of your projects
list.
As with the bike shed you will receive a million
comments on the small prime number code but not
with your text editor!

Oh, and if you were bothered by Uri's comments
then please do not worry. He is a morbidly obese
shut in. One of the aforementioned jaded losers. 
Nobody has seen him in months...his
doorways are now far to narrow to allow him out.
Even if he turns sideways.
I must hand it to him though, it is quite a novel
way to fight foreclosure!

Happy Days to You All!
Ralph Malph


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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 2767
***************************************


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