[31189] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2434 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 22 16:09:47 2009

Date: Fri, 22 May 2009 13:09:13 -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, 22 May 2009     Volume: 11 Number: 2434

Today's topics:
    Re: ampersand subroutine <news123@free.fr>
    Re: ampersand subroutine <nat.k@gm.ml>
    Re: ampersand subroutine <nat.k@gm.ml>
    Re: ampersand subroutine <uri@StemSystems.com>
    Re: ampersand subroutine <nat.k@gm.ml>
    Re: Archive::Zip and correct extension (mixture of Word <gcox@freeuk.com>
    Re: Archive::Zip and correct extension (mixture of Word <hjp-usenet2@hjp.at>
    Re: Capturing actual Browser output in perl <noreply@gunnar.cc>
    Re: comma operator <cwilbur@chromatico.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 22 May 2009 21:49:52 +0200
From: News123 <news123@free.fr>
Subject: Re: ampersand subroutine
Message-Id: <4a1701e0$0$17415$426a74cc@news.free.fr>

Hi Nathan,

Jumping in the midlle of a thread without reading the initial messages
is not always optimal.

This was my initial post starting the discussion about exit():
> For 99% of perl code I would give following advise:
> 
> Don't use ampersand for calling functions
> Don't use function prototypes
> Don't declare functions separately before their definition.
> Group your function definitions either roughly bottom up at the
> beginning of your script or group them all top down at the end of your
> script.
> In the latter case I'd suggest an explicit exit() statement before the
> function definitions in order to signal to a person reading the code,
> that no more code outside of function definitions will follow (except of
> course for potential BEGIN blocks)

exit() is the promise, that no more top level code will follow.

__END__ will not work in above scenario

comments may be wrong.

As so often: coding style especially in the perl community varies a lot.


bye

N

Nathan Keel wrote:
> News123 wrote:
> 
>> Nathan Keel wrote:
>>> Uri Guttman wrote:
>>>
>>>>>>>>> "SP" == Sherm Pendley <spamtrap@dot-app.org> writes:
>>>> SP> News123 <news123@free.fr> writes:
>>>>>>  In the latter case I'd suggest an explicit exit() statement
>>>>>>  before
>>>> the >> function definitions in order to signal to a person reading
>>>> the code, >> that no more code outside of function definitions will
>>>> follow
>>>>
>>>> SP> If you're communicating to a person, comments are far clearer:
>>>>
>>>> SP> # End main code body
>>>> SP> # Function definitions follow
>>>>
>>>> SP> Use exit() for its intended purpose, explicitly returning an
>>>> exit code SP> to the parent process.
>>>>
>>>> i disagree. in my top level programs i always put an explicit exit()
>>>> after the main line code ends.
>>> If it's Perl code you're talking about, why not use something better
>>> suited for that, if you might have code/routines/comments that could
>>> create problems?  exit() isn't the best method for preventing that
>>> problem, as much as I agree that it's not a bad idea for the same
>>> reasons, exit() isn't what I'd suggest.
>> What other command stops execution of a perl script non fatally and
>> without error?
>>
>> For me this is exit() or exit(0)
>>
>> For me exit() is the promise to the reader, that the script ends here.
>>
>> What would you suggest as clearer less confusing method to indicate,
>> that one hasn't to look for any further top code snippets?
> 
> 
> How about __END__? 
> 


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

Date: Thu, 21 May 2009 11:33:32 -0700
From: Nathan Keel <nat.k@gm.ml>
Subject: Re: ampersand subroutine
Message-Id: <QmDRl.132374$ew.119028@newsfe24.iad>

Uri Guttman wrote:

>>>>>> "NK" == Nathan Keel <nat.k@gm.ml> writes:
> 
>   NK> Uri Guttman wrote:
>   >>>>>>> "NK" == Nathan Keel <nat.k@gm.ml> writes:
>   >> 
>   NK> Uri Guttman wrote:
>   >> >>>>>>> "NK" == Nathan Keel <nat.k@gm.ml> writes:
>   >> >> 
>   NK> Uri Guttman wrote:
>   >> >> >> 
>   >> >> >> i disagree. in my top level programs i always put an
>   >> >> >> explicit exit() after the main line code ends.
>   >> >> 
>   NK> If it's Perl code you're talking about, why not use something
>   NK> better suited for that, if you might have code/routines/comments
>   NK> that could create problems?  exit() isn't the best method for
>   NK> preventing that problem, as much as I agree that it's not a bad
>   NK> idea for the same reasons, exit() isn't what I'd suggest.
>   >> >> 
>   >> >> huh?? use what is better? exit is to exit and also tell the
>   >> >> reader than no more main line code will be executed. it serves
>   >> >> a dual purpose. not much else can do that.
>   >> 
>   NK> How about __END__?
>   >> 
>   >> you fell into the trap.
> 
>   NK> Not really.
> 
> yes you did. sorry to tell you that.

Oh come on.  Read what I said.  See below and stop being such a jerk.

>   >> what about the subs you want to put after the
>   >> top level main line code?
> 
>   NK> You said you put an exit() at the end in case any comments or
>   code you
>   NK> didn't want executed followed it.  In fact, invalid syntax
>   following an
>   NK> exit will still fail anyway.  Which did you mean then?
> 
> i said no more mainline code will be executed after the exit(). the
> subs are to be put after the exit. they are not mainline code. learn
> the difference.

I know the difference, enough with the attitude already.

Here's what YOU said:

"i disagree. in my top level programs i always put an explicit exit()
after the main line code ends. comments can lie and there could be left
over code below that would execute that shouldn't."

Those are YOUR words.  "left over code that could execute that
shouldn't", and your solution is "exit" by default?


>   >> if they are after __END__ they won't be
>   >> parsed.
> 
>   NK> Yes, that is correct, so I must have misread your reasoning for
>   using
>   NK> exit()?  Why do you use exit again?
> 
> read my posts again.

I did, you should do the same and not think any time someone discusses
something with you that they are trying to fight with you.

>   >> the issue is to notify the reader than main line code has
>   >> ended and to explicitly return a value to end the process. exit()
>   >> is correct here.
> 
>   NK> How about a comment that that's the end, or no further code, or?
>   NK> I get what you mean about they know anything that follows is sub
>   NK> routines, comments, documentation, etc., so I guess that's what
>   NK> you meant then.  I'd just throw in a commment if I felt it was
>   NK> needed, but I'm not claiming your method isn't fine, I just
>   don't NK> think it's necessary.
> 
> comments can lie. i said that before. code doesn't lie.
> 

It's unfortunate that you'll have random lines of code that could
execute that you don't want, and your solution is to use exit.  Your
choice, doesn't affect me, so by all means, go ahead... I just don't
agree (big deal).


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

Date: Fri, 22 May 2009 12:56:20 -0700
From: Nathan Keel <nat.k@gm.ml>
Subject: Re: ampersand subroutine
Message-Id: <FrDRl.132376$ew.84913@newsfe24.iad>

News123 wrote:

> Hi Nathan,
> 
> Jumping in the midlle of a thread without reading the initial messages
> is not always optimal.

Agreed, and top posting sucks.

> This was my initial post starting the discussion about exit():
>> For 99% of perl code I would give following advise:
>> 
snip what I have already read.

> 
> exit() is the promise, that no more top level code will follow.

And it shouldn't anyway.
 
> __END__ will not work in above scenario

True.

> comments may be wrong.

Maybe, but irrelevant.

> As so often: coding style especially in the perl community varies a
> lot.

Indeed.

> 
> bye
> 

Bye.


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

Date: Fri, 22 May 2009 15:57:20 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: ampersand subroutine
Message-Id: <87hbzcc3mn.fsf@quad.sysarch.com>

>>>>> "NK" == Nathan Keel <nat.k@gm.ml> writes:

  NK> It's unfortunate that you'll have random lines of code that could
  NK> execute that you don't want, and your solution is to use exit.  Your
  NK> choice, doesn't affect me, so by all means, go ahead... I just don't
  NK> agree (big deal).

you don't have a solution. __END__ is not one. keep barking and maybe
someone will pay attention to you. your perl skills don't warrant it.

as for your not agreeing with me, i will file that into /dev/null where
it belongs. yes, that is another insult. you seem to attract them. note
that others don't. seems to me you are the cause.

uri

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


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

Date: Fri, 22 May 2009 13:03:05 -0700
From: Nathan Keel <nat.k@gm.ml>
Subject: Re: ampersand subroutine
Message-Id: <0yDRl.45759$%_2.43045@newsfe04.iad>

Uri Guttman wrote:

>>>>>> "NK" == Nathan Keel <nat.k@gm.ml> writes:
> 
>   NK> It's unfortunate that you'll have random lines of code that
>   could
>   NK> execute that you don't want, and your solution is to use exit. 
>   Your NK> choice, doesn't affect me, so by all means, go ahead... I
>   just don't NK> agree (big deal).
> 
> you don't have a solution.

I do, we just disagree.

> __END__ is not one.

It can be, if you're worried about comments having code that will
potentially run that you don't want to run.

> keep barking and maybe  
> someone will pay attention to you.

You're a dick, you always are a dick here to anyone that doesn't
mindlessly agree with you.

> your perl skills don't warrant it. 

A true dick thing to say.  My skills have nothing to do with disagreeing
with you (oh God, AGAIN).  Grow up.

> as for your not agreeing with me, i will file that into /dev/null
> where it belongs.

Yes, you've said that before, but you seem to enjoy being a dick and
fighting with people.  Learn to use your shift key while you're at it.

> yes, that is another insult.

Yes, that's all you seem to do.

> you seem to attract  
> them.

You seem to think more highly of yourself than you are deserving of. 
You just can't deal with the fact I don't put up with your bullshit. 
You're not that important to me, I've got to be honest.  I'm just
posting here, and you being an arrogant twat doesn't really mean dick.

> note that others don't.

I guess that explains the literally thousands of archived posts of you
being an arrogant prick to people any time that discuss something and
don't agree with your stubborn methods.  Who really cares?  Get thicker
skin, for God's sake!

> seems to me you are the cause.  

Yes, I'm aware you think everyone else but YOU have the attitude
problem.  I also realize that you're such a fucking prick that you
can't help yourself and you could never accept that anyone but you
could be right about anything, including their own feelings about a
topic.  In closing, I don't give a damn who you think you are and how
you think you can treat people, you're a piece of shit in my opinion.

> uri
 
nal cake.



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

Date: Fri, 22 May 2009 17:00:14 +0100
From: Geoff Cox <gcox@freeuk.com>
Subject: Re: Archive::Zip and correct extension (mixture of Word and PowerPoint files)?
Message-Id: <jvid155elm7q6hb5h0khbqb7ie023esnir@4ax.com>

On Fri, 22 May 2009 13:18:51 +0200, "Peter J. Holzer"
<hjp-usenet2@hjp.at> wrote:

>On 2009-05-22 10:05, Bart Lateur <bart.lateur@pandora.be> wrote:
>> Geoff Cox wrote:
>>>Most of several thousand zip files, on a website, contained a single
>>>Word doc. On moving the files to a CD I extracted all the zip files,
>>>giving them a .doc extension and forgot that a few hundred where
>>>either PowerPoint files or Excel files.
>>
>> Eh, what?
>>
>> A ZIP file contains a compressed file tree, including ibnformation of
>> the exact original filename.
>>
>> If your users didn't mess up the extensions, then you can just find them
>> in the archive.
>
>Yes, and the OP already noticed this. It was just that he originally
>assumed that all the files were doc files, so he didn't have to look at
>the file name in the archive at all. But then he noticed that this
>wasn't the case and that he has to combine the original extension with
>the newly created basename. Please read the whole thread before starting
>a discussion about a problem which is already solved.
>
>	hp

thanks Peter!

Cheers

Geoff


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

Date: Fri, 22 May 2009 13:18:51 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Archive::Zip and correct extension (mixture of Word and PowerPoint files)?
Message-Id: <slrnh1d2gr.vag.hjp-usenet2@hrunkner.hjp.at>

On 2009-05-22 10:05, Bart Lateur <bart.lateur@pandora.be> wrote:
> Geoff Cox wrote:
>>Most of several thousand zip files, on a website, contained a single
>>Word doc. On moving the files to a CD I extracted all the zip files,
>>giving them a .doc extension and forgot that a few hundred where
>>either PowerPoint files or Excel files.
>
> Eh, what?
>
> A ZIP file contains a compressed file tree, including ibnformation of
> the exact original filename.
>
> If your users didn't mess up the extensions, then you can just find them
> in the archive.

Yes, and the OP already noticed this. It was just that he originally
assumed that all the files were doc files, so he didn't have to look at
the file name in the archive at all. But then he noticed that this
wasn't the case and that he has to combine the original extension with
the newly created basename. Please read the whole thread before starting
a discussion about a problem which is already solved.

	hp


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

Date: Fri, 22 May 2009 17:55:27 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Capturing actual Browser output in perl
Message-Id: <77o082F1ijsgdU1@mid.individual.net>

digz wrote:
> #!/usr/bin/perl
> use LWP;
> my $browser = LWP::UserAgent->new;
> my $response = $browser->get( "http://lkml.org" );
> print( $response->content );
> 
> In this program I am trying to get the output as the browser displays
> it , not the actual HTML page with all the tags .., that $response-
> content returns.

You may want to check out:

     http://search.cpan.org/dist/html2text/

     http://search.cpan.org/perldoc?HTML::FormatText::Html2text

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Fri, 22 May 2009 11:46:00 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: comma operator
Message-Id: <86iqjt2laf.fsf@mithril.chromatico.net>

>>>>> "FS" == Franken Sense <frank@example.invalid> writes:

    FS> In Dread Ink, the Grave Hand of Charlton Wilbur Did Inscribe:

    >> Consider choosing a different font for your terminal window or
    >> your IDE.  The difference between ( and { is fairly significant.

    FS> My sysadmin buddy thought I should continue with perl using
    FS> Eclipse. 

Yes, and?  Has Eclipse suddenly been altered so that you cannot change
the font?  Or do you not recognize "IDE" as a general term for the class
of things of which Eclipse is a member?

Charlton


-- 
Charlton Wilbur
cwilbur@chromatico.net


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

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


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