Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Good Golly Miss Molly Perl. Been so long.

1 view
Skip to first unread message

Andy

unread,
Nov 25, 2009, 7:45:10 AM11/25/09
to
Good Golly Miss Molly Perl. Been so long.

You Perl people are great motivators.

I have an urge to re-perl again.

Any iPhone perl I can carry around in my pocket?

Best,

Andy
Perlotto

Tad McClellan

unread,
Nov 25, 2009, 11:09:57 AM11/25/09
to
Andy <a@b.c> wrote:

> I have an urge to re-perl again.


Please resist the urge.


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

Andy

unread,
Nov 25, 2009, 11:57:37 AM11/25/09
to
Tad McClellan <ta...@seesig.invalid> wrote in
news:slrnhgqlh0...@tadbox.sbcglobal.net:

> Andy <a@b.c> wrote:
>
>> I have an urge to re-perl again.
>
>
> Please resist the urge.


Well I probably should, but... but...

You folks were always so supportive.

I always liked the puzzlelike nature of the beast!

I have small goals..

Andy


Andy

unread,
Nov 25, 2009, 12:06:47 PM11/25/09
to
Tad McClellan <ta...@seesig.invalid> wrote in
news:slrnhgqlh0...@tadbox.sbcglobal.net:

> Andy <a@b.c> wrote:


>
>> I have an urge to re-perl again.
>
>
> Please resist the urge.


Good golly,

It's been a good six years.

What's this about Strawberry Perl?!?

Should I bother? What's the local flavor these days?

Win7.

64-bit???

Best,

Andy

Charlton Wilbur

unread,
Nov 25, 2009, 12:05:38 PM11/25/09
to
>>>>> "A" == Andy <a@b.c> writes:

A> Any iPhone perl I can carry around in my pocket?

The terms of the iPhone App Store forbid any application that contains
an interpreter, so you're in unsupported territory if you try. And if
you have to ask, you're probably better off staying out of unsupported
territory.

Charlton


--
Charlton Wilbur
cwi...@chromatico.net

Andy

unread,
Nov 25, 2009, 12:10:35 PM11/25/09
to
#!/usr/bin/perl

# PERLotto 1.3
# Your Customizable Lotto Ticket Checker.
#
# Copyright (c) 2002, 2003 Andy Burns. All rights reserved.

# Email y...@comcast.net with questions/answers

##### THIS CODE IS NOT PRETTY BUT IT WORKS.
##### USE AT YOUR OWN RISK!

# Fixed in version 1.3:
# Added missing games file error cheking.
# Fixed in version 1.2:
# Don't print "--0" for no-hit games
# Cosmetic print statement adjustments.
# Added missing "official" bonus winning number error checks.
# Fixed in version 1.1:
# Print to screen instead of file.

# Read or setup 'perlotto.cfg" variables

SETOPTIONS:

open( IN, "<perlotto.cfg" ) or goto SETTINGS;
@a = ("");
while (<IN>) {
chomp;
$a[ $. - 1 ] = $_;
}

close(IN) || die "Error closing config file.\n";

$lotto_Max_Number = $a[0];
$picks_Per_Game = $a[1];
$bonus_Ball_On = $a[2];
$bonus_Max_Number = $a[3];
$bonus_Ball = 0;

goto MAINMENU;

SETTINGS:
print "\n\n-- SETTINGS --\n\n";
print "\n Does your lotto use a \"bonus ball\"? (y/n): ";
chomp( $bonus_Ball_On = <STDIN> );
$bonus_Ball_On = lc( substr( $bonus_Ball_On, 0, 1 ) );
if ( $bonus_Ball_On eq 'y' ) {
print "\n What's the highest bonus number allowed? ";
chomp( $bonus_Max_Number = <STDIN> );
}
else {
$bonus_Max_Number = 0;
}
print "\n How many numbers are in your main lotto game? ";
chomp( $picks_Per_Game = <STDIN> );
print "\n What's the highest number allowed? ";
chomp( $lotto_Max_Number = <STDIN> );

if ( $bonus_Ball_On eq 'y' ) {
$picks_Per_Game = $picks_Per_Game + 1;
}
open( OUT, ">perlotto.cfg" );
print OUT "$lotto_Max_Number\n";
print OUT "$picks_Per_Game\n";
print OUT "$bonus_Ball_On\n";
print OUT "$bonus_Max_Number\n";
close OUT || die "Couldn't close 'perlotto.cfg file.\n";

MAINMENU:
goto SETOPTIONS if ( $lotto_Max_Number eq undef );

print "\n\n-- MAIN MENU --\n\n";
print " 1 Check games.\n\n";
print " 2 Setup Lotto rules.\n\n";
print " Selection: ";
chomp( $choice = <STDIN> );
$choice = substr( $choice, 0, 1 );

if ( $choice == 1 ) {
goto BEGINPLAY;
}
elsif ( $choice == 2 ) {
goto SETTINGS;
}
else {
print " ALERT: Answer not understood. Try again.\n";
goto MAINMENU;
}

BEGINPLAY:

print "\n Enter winning numbers separated by spaces: ";
chomp( $input = <STDIN> );
@winners = ( split '\s+', $input );

foreach (@winners) {
if (/\D/) {
print " ALERT: Non-numeric entry, $_. Try again.\n";
goto BEGINPLAY;
}

if ( @winners < $picks_Per_Game ) {
print " ALERT: Missing ", $picks_Per_Game - @winners,
" numbers. Try again.\n";
goto BEGINPLAY;
}

if ( @winners > $picks_Per_Game ) {
print " ALERT: Extra ", @winners - $picks_Per_Game,
" numbers. Try again.\n";
goto BEGINPLAY;
}
}

if ( $bonus_Ball_On eq 'y' ) {
$bonus_Ball = pop (@winners);
}

foreach my $i ( 0 .. $#winners ) {
foreach my $j ( $i + 1 .. $#winners ) {
if ( $winners[$i] == $winners[$j] ) {
print " ALERT: Duplicate number '$winners[$i]'. Try again.
\n";
goto BEGINPLAY;
}
}
}
if ( $bonus_Ball_On eq 'y' ) {
push ( @winners, $bonus_Ball );
}

if ( $bonus_Ball_On eq 'y' ) {
$bonus_Ball = pop (@winners);
foreach (@winners) {
if ( $_ > $lotto_Max_Number ) {
print
"n ALERT: Number '$_' is above Lotto max:
$lotto_Max_Number.\n";
goto BEGINPLAY;
}
}
if ( $bonus_Ball > $bonus_Max_Number ) {
print
"\n ALERT: Number '$bonus_Ball' is above the Bonus max:
$bonus_Max_Number.\n";
goto BEGINPLAY;
}
if ( $bonus_Ball < 1 ) {
print "\n ALERT: Bonus number is less than 1. Try again.\n";
goto BEGINPLAY;
}

if ( $bonus_Ball eq /\D/ ) {
print "\n ALERT: Non-numeric bonus number $_. Try again.\n";
goto BEGINPLAY;
}
}

foreach (@winners) {
if ( $_ > $lotto_Max_Number ) {
print
"\n ALERT: Number '$_' is above Lotto max: $lotto_Max_Number.
\n";
goto BEGINPLAY;
}
}

open( IN, "<games.txt" ) or die "Can't open 'games' file: $!\n";

open(OUT, ">results.txt");

system("cls");

if ( $bonus_Ball_On eq 'y' ) {
$short = $picks_Per_Game - 1;
print OUT "\nLotto: $short/$lotto_Max_Number";
}
else {
print OUT "\nLotto: $picks_Per_Game/$lotto_Max_Number";
}
if ( $bonus_Ball_On eq 'y' ) {
print OUT " + 1/$bonus_Max_Number\n";
}
else {
print OUT "\n";
}
print OUT "\nWinning numbers: @winners";

if ( $bonus_Ball_On eq 'y' ) {
print OUT " + $bonus_Ball\n\n";
}
else {
print OUT "\n";
}

while (<IN>) {
if ( /^\// | /^$/ ) {
print OUT ;
next;
}

chomp;

# Game File Numbers Error-Checking
@game = split;
if ( $bonus_Ball_On eq 'y' ) {
$game_bonus_Ball = pop @game;
print OUT "\nALERT: Bonus number '$game_bonus_Ball' is above the
Bonus max: $bonus_Max_Number.\n"
if $game_bonus_Ball gt $bonus_Max_Number;
print OUT "\nALERT: Bonus number '$game_bonus_Ball' is below
one.\n"
if $game_bonus_Ball < 1;
print OUT
"\nALERT: Non-numeric entry $game_bonus_Ball in bonus ball
below.\n"
if $game_bonus_Ball =~ /\D/;
}
print OUT "\nALERT: Two few numbers in game below.\n" if @game <
@winners;
print OUT "\nALERT: Two many numbers in game below.\n" if @game >
@winners;

$picks = 0;
undef(@picked);

## Games File Error-Checking

L2:
foreach my $i ( 0 .. $#game ) {
foreach my $j ( $i + 1 .. $#game ) {
if ( $game[$i] == $game[$j] ) {
print OUT "\nALERT: Duplicate number '$game[$i]' in game
below.\n";
last L2;
}
}
if ( $game[$i] < 1 ) {
print OUT "ALERT: Number is below one in game below.\n";
}
}

## Check game file for winners

foreach my $y (@winners) {
for my $x (@game) {
if ( $y == $x ) {
$picks++;
push @picked, $x;
}
}
}

## End Check game file for winners

## Start console output

if ( $bonus_Ball_On eq 'y' ) {
$b = 0;

# push @game, $game_bonus_Ball;
if ( $picks != 0 ) {
print OUT "@game $game_bonus_Ball --$picks";
}
else {
print OUT "@game $game_bonus_Ball";
}
if ( $bonus_Ball == $game_bonus_Ball ) {
push @picked, $game_bonus_Ball;
$b = 1;
}

if ( $#picked > -1 ) {
if ( $b == 1 ) {
if ( $picks == 0 ) {
print OUT " --0b Hit: @picked\n";
}
else {
print OUT "b Hit: @picked\n";
}
}
else {
print OUT " Hit: @picked\n";
}
}
else {
print OUT "\n";
}
}

if ( $bonus_Ball_On ne 'y' ) {
if ( $picks != 0 ) {
print OUT "@game --$picks";
if ( $#picked > -1 ) {
print OUT " Hit: @picked\n";
}
else {
print OUT "\n";
}
}
else {
print OUT "@game\n";
}
}
## End console output
}
print "\n<Press Return to exit>";
chomp( $lotto_Max_Number = <STDIN> );


I can't reason with my own code.

It's been ages.

Andy

Uri Guttman

unread,
Nov 25, 2009, 12:27:48 PM11/25/09
to

this is some of the worst perl code i have ever seen. it is basic
written in perl. 10 or more gotos. NOT ONE SUB. no strict or warnings.
spaghetti logic all the way. i am ashamed to see this code in
public. you should be ashamed too.

>>>>> "A" == Andy <a@b.c> writes:

A> I can't reason with my own code.

A> It's been ages.

because it sucked to begin with. learn how to code without gotos.

uri

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

Andy

unread,
Nov 25, 2009, 12:28:17 PM11/25/09
to
Charlton Wilbur <cwi...@chromatico.net> wrote in
news:86zl6ai...@mithril.chromatico.net:

>>>>>> "A" == Andy <a@b.c> writes:
>
> A> Any iPhone perl I can carry around in my pocket?
>
> The terms of the iPhone App Store forbid any application that contains
> an interpreter, so you're in unsupported territory if you try. And if
> you have to ask, you're probably better off staying out of unsupported
> territory.
>
> Charlton


I kinda/sorta imagined as much.

Shame the iPhone's OS/X under the hood Unix shouls be so available.

What's a mother to do?!? <G>

Andy


Andy

unread,
Nov 25, 2009, 12:33:01 PM11/25/09
to
"Uri Guttman" <u...@StemSystems.com> wrote in
news:878wdup...@quad.sysarch.com:

>
> this is some of the worst perl code i have ever seen. it is basic
> written in perl. 10 or more gotos. NOT ONE SUB. no strict or warnings.
> spaghetti logic all the way. i am ashamed to see this code in
> public. you should be ashamed too.
>
>>>>>> "A" == Andy <a@b.c> writes:
>
> A> I can't reason with my own code.
>
> A> It's been ages.
>
> because it sucked to begin with. learn how to code without gotos.
>
> uri

uri,

I was given that advice more than once!

You're a Perl hero of mine!

Best,

Andy

Glenn Jackman

unread,
Nov 25, 2009, 12:34:30 PM11/25/09
to
At 2009-11-25 12:27PM, "Uri Guttman" wrote:
> this is some of the worst perl code i have ever seen. it is basic
> written in perl. 10 or more gotos. NOT ONE SUB. no strict or warnings.
> spaghetti logic all the way. i am ashamed to see this code in
> public. you should be ashamed too.

Come on now. Subroutines are _so_ 1968.

--
Glenn Jackman
Write a wise saying and your name will live forever. -- Anonymous

Rosalind Mitchell

unread,
Nov 25, 2009, 12:38:42 PM11/25/09
to
On Wed, 2009-11-25 at 17:34 +0000, Glenn Jackman wrote:
> At 2009-11-25 12:27PM, "Uri Guttman" wrote:
> > this is some of the worst perl code i have ever seen. it is basic
> > written in perl. 10 or more gotos. NOT ONE SUB. no strict or warnings.
> > spaghetti logic all the way. i am ashamed to see this code in
> > public. you should be ashamed too.
>
> Come on now. Subroutines are _so_ 1968.
>

I blame that Michael Jackson, myself.

Wonder what happened to him? He was never so good after Thriller,
though his books about beer and whisky were all right.

Uri Guttman

unread,
Nov 25, 2009, 12:54:14 PM11/25/09
to
>>>>> "A" == Andy <a@b.c> writes:

A> "Uri Guttman" <u...@StemSystems.com> wrote in
A> news:878wdup...@quad.sysarch.com:

>>
>> this is some of the worst perl code i have ever seen. it is basic
>> written in perl. 10 or more gotos. NOT ONE SUB. no strict or warnings.
>> spaghetti logic all the way. i am ashamed to see this code in
>> public. you should be ashamed too.
>>
>>>>>>> "A" == Andy <a@b.c> writes:
>>
A> I can't reason with my own code.
>>
A> It's been ages.
>>
>> because it sucked to begin with. learn how to code without gotos.
>>
>> uri

A> uri,

A> I was given that advice more than once!

so why haven't you fixed that mess? or learned how to code properly.

A> You're a Perl hero of mine!

you are no acolyte if you don't listen. i don't want to be your hero if
you don't learn to code properly.

Adam Russell

unread,
Nov 25, 2009, 1:29:14 PM11/25/09
to
Andy wrote:
> Good Golly Miss Molly Perl. Been so long.
>
> You Perl people are great motivators.
>
> I have an urge to re-perl again.
>
> Any iPhone perl I can carry around in my pocket?
No, but there is a perl port to the SymbianOS.
I have made some contributions to it so I can say
that it is currently in a working state provided you
configure a Symbian development environment.

J�rgen Exner

unread,
Nov 25, 2009, 1:30:48 PM11/25/09
to
Andy <a@b.c> wrote:
>#!/usr/bin/perl

Missing:
use warnings;
use strict;

># PERLotto 1.3
># Your Customizable Lotto Ticket Checker.
>#
># Copyright (c) 2002, 2003 Andy Burns. All rights reserved.
>
># Email y...@comcast.net with questions/answers
>
>##### THIS CODE IS NOT PRETTY BUT IT WORKS.
>##### USE AT YOUR OWN RISK!
>
># Fixed in version 1.3:
># Added missing games file error cheking.
># Fixed in version 1.2:
># Don't print "--0" for no-hit games
># Cosmetic print statement adjustments.
># Added missing "official" bonus winning number error checks.
># Fixed in version 1.1:
># Print to screen instead of file.
>
># Read or setup 'perlotto.cfg" variables
>
>SETOPTIONS:
>
>open( IN, "<perlotto.cfg" ) or goto SETTINGS;

Yikes! Why goto? This is most definitely not a place where it needed.

>@a = ("");

Why?

>while (<IN>) {
> chomp;
> $a[ $. - 1 ] = $_;

Yikes! Why not a simple push()?
Or actually because you are just reading all lines and adding them to
the array anyway you can much easier just slurp in the whole file:

@a = <IN>;
chomp @a;

>}
>
>close(IN) || die "Error closing config file.\n";

Why hiding the file name? Why hiding the reason for the error?

>
>$lotto_Max_Number = $a[0];
>$picks_Per_Game = $a[1];
>$bonus_Ball_On = $a[2];
>$bonus_Max_Number = $a[3];
>$bonus_Ball = 0;
>
>goto MAINMENU;

Yikes! Yes, a good programmer can program BASIC in any programming
language. But that doesn't mean it is a good thing to do so.
Learn about functions and use them! There are very few cases where a
goto() is justified, none of those in your program fall in that group.


>SETTINGS:
>print "\n\n-- SETTINGS --\n\n";
>print "\n Does your lotto use a \"bonus ball\"? (y/n): ";
>chomp( $bonus_Ball_On = <STDIN> );
>$bonus_Ball_On = lc( substr( $bonus_Ball_On, 0, 1 ) );
>if ( $bonus_Ball_On eq 'y' ) {

There are more elegant ways to standardize/check user input, but I
suppose if it works it's ok.

> print "\n What's the highest bonus number allowed? ";
> chomp( $bonus_Max_Number = <STDIN> );
>}
>else {
> $bonus_Max_Number = 0;
>}
>print "\n How many numbers are in your main lotto game? ";
>chomp( $picks_Per_Game = <STDIN> );
>print "\n What's the highest number allowed? ";
>chomp( $lotto_Max_Number = <STDIN> );
>
>if ( $bonus_Ball_On eq 'y' ) {
> $picks_Per_Game = $picks_Per_Game + 1;
>}
>open( OUT, ">perlotto.cfg" );
>print OUT "$lotto_Max_Number\n";
>print OUT "$picks_Per_Game\n";
>print OUT "$bonus_Ball_On\n";
>print OUT "$bonus_Max_Number\n";
>close OUT || die "Couldn't close 'perlotto.cfg file.\n";
>
>MAINMENU:
>goto SETOPTIONS if ( $lotto_Max_Number eq undef );

What is this supposed to do? The string value of undef is the empty
string, so you are comparing $lotto_Max_Number with the empty string.
Why and why not a straight eq with the empty string?

I stopped looking here, this code is just too convoluted, including way
to many gotos all over place. Impossible to follow the execution flow
without a flow chart.
Learn about structured programming (any introductory class into computer
science will do) and while you are at it, please add some comments, too.

jue

Martijn Lievaart

unread,
Nov 25, 2009, 5:59:58 PM11/25/09
to
On Wed, 25 Nov 2009 17:38:42 +0000, Rosalind Mitchell wrote:

> I blame that Michael Jackson, myself.
>
> Wonder what happened to him? He was never so good after Thriller,
> though his books about beer and whisky were all right.

Ughhh, Jackson diagrams. The horror. Took ages to draw, added nothing to
the documentation.

I agree his beer books are a must have.

M4

Uri Guttman

unread,
Nov 25, 2009, 6:14:19 PM11/25/09
to
>>>>> "RM" == Rosalind Mitchell <stea...@golgonooza.co.uk> writes:

RM> On Wed, 2009-11-25 at 17:34 +0000, Glenn Jackman wrote:
>> At 2009-11-25 12:27PM, "Uri Guttman" wrote:
>> > this is some of the worst perl code i have ever seen. it is basic
>> > written in perl. 10 or more gotos. NOT ONE SUB. no strict or warnings.
>> > spaghetti logic all the way. i am ashamed to see this code in
>> > public. you should be ashamed too.
>>
>> Come on now. Subroutines are _so_ 1968.
>>

RM> I blame that Michael Jackson, myself.

RM> Wonder what happened to him? He was never so good after Thriller,
RM> though his books about beer and whisky were all right.

and now both are dead so it is back to the confusion of which dead
michael jackson are you referring to?

Ben Morrow

unread,
Nov 25, 2009, 6:46:19 PM11/25/09
to

Quoth Adam Russell <ac.ru...@live.com>:

> No, but there is a perl port to the SymbianOS.
> I have made some contributions to it so I can say
> that it is currently in a working state provided you
> configure a Symbian development environment.

Really? Last time I looked at perl/S60 it was nominally functional, but
practically useless, and I assumed that since Jarkko'd stopped working
on it the port was dead. Are there any sane interfaces to the native S60
APIs, like PyS60 has?

Ben

Adam Russell

unread,
Nov 25, 2009, 11:23:46 PM11/25/09
to

"Ben Morrow" <b...@morrow.me.uk> wrote in message
news:b7s0u6-...@osiris.mauzo.dyndns.org...
That is what I am currently working on...giving a perl
face to S60. There are two of us mainly, me and Osvaldo Villalon. We
had quite a bit of work to just getting Jarkko's work cohesive with
current sources.
We work on this as our time allows. You know the deal:
this is an all volunteer effort etc etc
Between work, grad school, home life, yeah, I get to it
when I can. :)
Anyway, I take objection to your negativity. This is the
sort of thing that pesters what should be a happy open source community.
What I wish you would have said is:
"Really? I am jealous of the S60 functionality the
python guys have. Where are you in development of this and can you give
us
a road map to where you want to go in terms of allowing a richer set
of APIs? What can interested parties do to help?"
I have answers to these questions but, sadly, you didn't
ask. Did you?

Shmuel Metz

unread,
Nov 26, 2009, 10:08:43 AM11/26/09
to
In <878wdup...@quad.sysarch.com>, on 11/25/2009

at 12:27 PM, "Uri Guttman" <u...@StemSystems.com> said:

>because it sucked to begin with. learn how to code without gotos.

There's nothing wrong with goto when used properly. Like any tool, it can
be and often is misused, but it's useful in its place.

--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to spam...@library.lspace.org

Uri Guttman

unread,
Nov 26, 2009, 12:16:41 PM11/26/09
to
>>>>> "S(J)M" == Shmuel (Seymour J ) Metz <spam...@library.lspace.org.invalid> writes:

S(J)M> In <878wdup...@quad.sysarch.com>, on 11/25/2009


S(J)M> at 12:27 PM, "Uri Guttman" <u...@StemSystems.com> said:

>> because it sucked to begin with. learn how to code without gotos.

S(J)M> There's nothing wrong with goto when used properly. Like any
tool, it can S(J)M> be and often is misused, but it's useful in its
place.

if you consistantly or even occasionally use goto then i won't
recommend you for a job. magic goto being the only exception, perl has
little use for goto. you can easily code around it with all the great
flow control options we have. one trick is to use more subs and return
early from them.

and the OP's code is beyond redemption. he obviously CHOSE goto and no
subs which makes him a BASIC coder.

J�rgen Exner

unread,
Nov 26, 2009, 1:35:02 PM11/26/09
to
Shmuel (Seymour J.) Metz <spam...@library.lspace.org.invalid> wrote:
>In <878wdup...@quad.sysarch.com>, on 11/25/2009
> at 12:27 PM, "Uri Guttman" <u...@StemSystems.com> said:
>
>>because it sucked to begin with. learn how to code without gotos.
>
>There's nothing wrong with goto when used properly. Like any tool, it can
>be and often is misused, but it's useful in its place.

Yes, there are sometimes special cicumstances which occasionally justify
a goto. But none of the OP's calls fall into that category and actually
his resulting spaghetti code is a prime example why Edsger Dijkstra's
"Go To Statement Considered Harmful" is as valid today as it was 40
years ago.

jue

Ben Morrow

unread,
Nov 26, 2009, 2:03:47 PM11/26/09
to
[please don't send email CCs of newsgroup posts]

Quoth "Adam Russell" <ac.ru...@live.com>:


>
> "Ben Morrow" <b...@morrow.me.uk> wrote in message
> news:b7s0u6-...@osiris.mauzo.dyndns.org...
> >
> > Quoth Adam Russell <ac.ru...@live.com>:
> >> No, but there is a perl port to the SymbianOS.
> >> I have made some contributions to it so I can say
> >> that it is currently in a working state provided you
> >> configure a Symbian development environment.
> >
> > Really? Last time I looked at perl/S60 it was nominally functional, but
> > practically useless, and I assumed that since Jarkko'd stopped working
> > on it the port was dead. Are there any sane interfaces to the native S60
> > APIs, like PyS60 has?
> That is what I am currently working on...giving a perl
> face to S60. There are two of us mainly, me and Osvaldo Villalon. We
> had quite a bit of work to just getting Jarkko's work cohesive with
> current sources.
> We work on this as our time allows. You know the deal:
> this is an all volunteer effort etc etc
> Between work, grad school, home life, yeah, I get to it
> when I can. :)

I understand that. I was certainly not intending to disparage your work,
or others', so if what I said came across that way I apologise.

> Anyway, I take objection to your negativity. This is the
> sort of thing that pesters what should be a happy open source community.
> What I wish you would have said is:
> "Really? I am jealous of the S60 functionality the
> python guys have. Where are you in development of this and can you give
> us
> a road map to where you want to go in terms of allowing a richer set
> of APIs? What can interested parties do to help?"
> I have answers to these questions but, sadly, you didn't
> ask. Did you?

Assume I did.

Ben

RedGrittyBrick

unread,
Nov 27, 2009, 4:44:09 AM11/27/09
to

Shmuel (Seymour J.) Metz wrote:
> In <878wdup...@quad.sysarch.com>, on 11/25/2009
> at 12:27 PM, "Uri Guttman" <u...@StemSystems.com> said:
>
>> because it sucked to begin with. learn how to code without gotos.
>
> There's nothing wrong with goto when used properly. Like any tool, it can
> be and often is misused, but it's useful in its place.
>

I've never found a situation where I thought it would be useful to use
goto. When modifying other people's code that contains gotos it has
almost invariably made my job harder. Much harder.

I'm sure gotos can be used well, its just that I've never encountered a
good use of goto in the code I've had to grapple with in thirty years of
software development.

Clearly other people's experience differs.

--
RGB

Randal L. Schwartz

unread,
Nov 27, 2009, 11:37:14 AM11/27/09
to
>>>>> "RedGrittyBrick" == RedGrittyBrick <RedGrit...@spamweary.invalid> writes:

RedGrittyBrick> I've never found a situation where I thought it would be
RedGrittyBrick> useful to use goto. When modifying other people's code that
RedGrittyBrick> contains gotos it has almost invariably made my job
RedGrittyBrick> harder. Much harder.

In the first Camel, we had precisely *one* program that included a goto, and
it was a contributed program at that (not one that either Larry or I had
written).

The amount of flack we took for that far exceeded anything else we had done
poorly on the book. :)

print "Just another Perl hacker,"; # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

Shmuel Metz

unread,
Nov 29, 2009, 12:02:30 AM11/29/09
to
In <4b0f9f6c$0$2534$da0f...@news.zen.co.uk>, on 11/27/2009

at 09:44 AM, RedGrittyBrick <RedGrit...@spamweary.invalid> said:

>I've never found a situation where I thought it would be useful to use
>goto.

I have, although I've certainly written programs that contained no goto
and have never written one in Perl.

>When modifying other people's code that contains gotos it has almost
>invariably made my job harder. Much harder.

Was that an aberration, or were those portions of the code not using goto
also hard to modify. I've never seen serious misuse of goto occur in
isolation; there have always be other instances of poor style in the same
programs.

>I'm sure gotos can be used well,

Read Knuth's article "Structured Programming Using GOTO."

Shmuel Metz

unread,
Nov 28, 2009, 11:56:40 PM11/28/09
to
In <86ocmnu...@blue.stonehenge.com>, on 11/27/2009

at 08:37 AM, mer...@stonehenge.com (Randal L. Schwartz) said:

>The amount of flack we took for that far exceeded anything else we had
>done poorly on the book. :)

Suggesting that the issue was that it wasn't PC rather than some reasoned
objection to the specific use.

Randal L. Schwartz

unread,
Nov 29, 2009, 12:05:53 PM11/29/09
to
>>>>> "Shmuel" == Shmuel (Seymour J ) Metz <spam...@library.lspace.org.invalid> writes:

Shmuel> Suggesting that the issue was that it wasn't PC rather than some
Shmuel> reasoned objection to the specific use.

No, suggesting that we really should have known better than to include it, a
mistake I didn't repeat on the second Camel.

David Formosa (aka ? the Platypus)

unread,
Dec 2, 2009, 1:03:56 AM12/2/09
to
On Thu, 26 Nov 2009 10:08:43 -0500, Shmuel Metz <spam...@library.lspace.org.invalid> wrote:
[...]

> There's nothing wrong with goto when used properly. Like any tool, it can
> be and often is misused, but it's useful in its place.

Can you give an example of perl code where it would be better to use a goto (excluding
magic goto).

Uri Guttman

unread,
Dec 2, 2009, 1:46:25 AM12/2/09
to
>>>>> "DF" == David Formosa (aka ? the Platypus) <dfor...@usyd.edu.au> writes:

DF> On Thu, 26 Nov 2009 10:08:43 -0500, Shmuel Metz <spam...@library.lspace.org.invalid> wrote:
DF> [...]


>> There's nothing wrong with goto when used properly. Like any tool, it can
>> be and often is misused, but it's useful in its place.

DF> Can you give an example of perl code where it would be better to
DF> use a goto (excluding magic goto).

in lesser langs which don't have the flexible flow control that perl
has, you would use a goto to exit from several places into the same exit
handling code in a sub. i have even seen this done on cpan by quality
coders but goto doesn't ever need to be used like that. if you design
your flow well, you can exit a sub or block early instead and handle
flow that way which is a clean style. the key is seeing the different
ways you can flow your code and choosing the best one instead of the
first one you get. this is often what i see in poor code, a first choice
instead of thinking more and making a better choice.

rule: your code is the recorded history of your logical choices when
designing the program.

Dr.Ruud

unread,
Dec 2, 2009, 2:58:36 PM12/2/09
to
Shmuel (Seymour J.) Metz wrote:
> David Formosa:

>> Can you give an example of perl code where it would be better to use a
>> goto (excluding magic goto).
>

> I haven't run into a case where I needed a goto in Perl, but that doesn't
> mean that there aren't cases where it is useful. I'd certainly want any
> use of goto to include a comment as to why the specific use was
> appropriate.

Idem labels.

--
Ruud

Martijn Lievaart

unread,
Dec 2, 2009, 4:01:09 PM12/2/09
to

Breaking out of multi level loops with next or last does not warrant such
a comment imho. Obviously, the label names should be documentative.

M4

Charlton Wilbur

unread,
Dec 2, 2009, 6:52:51 PM12/2/09
to
>>>>> "DF" == David Formosa (aka ? the Platypus) <dfor...@usyd.edu.au> writes:

DF> On Thu, 26 Nov 2009 10:08:43 -0500, Shmuel Metz <spam...@library.lspace.org.invalid> wrote:

>> There's nothing wrong with goto when used properly. Like any
>> tool, it can be and often is misused, but it's useful in its
>> place.

DF> Can you give an example of perl code where it would be better to
DF> use a goto (excluding magic goto).

I can't give an example of Perl code where goto is the best solution,
because Perl has last LABEL, next LABEL, and redo LABEL. In C, break
and continue have much simpler semantics, and so goto is more necessary.

The canonical place I've seen goto used in C is to jump to cleanup code
in a function to do something that is conceptually simple but which
requires a lot of setup and teardown. So you have 100 lines of setup,
20-30 lines of actually doing something, and 100 lines of teardown and
cleanup -- if you fail at something partially through setup, you goto
the beginning of the cleanup. You can do much the same thing by nesting
if-then-else structures, but then you wind up repeating the same code,
once to deal with failure in the if-then-else nest, and once to deal
with cleanup outside the if-then-else nest. The goto can make things
considerably easier to read and the logic simpler to follow.

Thus:

int do_something (int a, int b, char *fn)
{
FILE *fp = NULL;
char *foo = NULL;

fp = fopen (....);
if (!fp)
goto CLEANUP;

foo = malloc(25);
if (!foo)
goto CLEANUP;

/* ... */

CLEANUP:
if (fp)
fclose(fp);

if (foo)
free (foo);
}

In Perl, first off, such a thing would not be as necessary because a lot
of cleanup can be triggered automatically when a thing goes out of
scope. But if you did need such a thing, you could do something like
this:

SETUP for (1)
{
open my $fh, '<', ...
or last SETUP;

my $dbh = DBI->connect (...)
or last SETUP;
}

$fh && close $fn;
$dbh && $dbh->disconnect;

There's no goto in the Perlish version, but that's because the flow
control in Perl is richer.

The assertion was that there is nothing wrong with goto when used
properly, and that goto is useful in its place; the fact that there are
likely no places in Perl code that are a proper place for goto does not
make that assertion invalid.

Charlton

--
Charlton Wilbur
cwi...@chromatico.net

Martijn Lievaart

unread,
Dec 3, 2009, 5:11:22 PM12/3/09
to
On Thu, 03 Dec 2009 14:01:48 -0500, Shmuel (Seymour J.) Metz wrote:

> In <l51ju6-...@news.rtij.nl>, on 12/02/2009


> at 10:01 PM, Martijn Lievaart <m...@rtij.nl.invlalid> said:
>
>>Breaking out of multi level loops with next or last does not warrant
>>such
>> a comment imho.
>

> Do you consider those to be gotos? I don't.

This was about commenting all labels. Maybe the OP meant all labels
referred by a goto.

M4

0 new messages