[16843] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4255 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 8 00:10:27 2000

Date: Thu, 7 Sep 2000 21:10:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <968386214-v9-i4255@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 7 Sep 2000     Volume: 9 Number: 4255

Today's topics:
    Re: Small golf problem (Abigail)
    Re: Small golf problem (Logan Shaw)
    Re: Small golf problem <rick.delaney@home.com>
    Re: Small golf problem <rick.delaney@home.com>
    Re: Small golf problem <yanick@babyl.sympatico.ca>
    Re: Small golf problem (Abigail)
    Re: Sorting again. (Abigail)
    Re: Stable sorting (Alan Barclay)
    Re: The Heartbreak of Inscrutable Perl Code (Abigail)
    Re: two questions- help (David Efflandt)
    Re: use strict: why? (Andrew Johnson)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 08 Sep 2000 01:26:00 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Small golf problem
Message-Id: <slrn8rgfvc.vlt.abigail@alexandra.foad.org>

Yanick Champoux (yanick@babyl.sympatico.ca) wrote on MMDLXIV September
MCMXCIII in <URL:news:XWUt5.243945$1h3.4538681@news20.bellglobal.com>:
][ Craig Berry <cberry@cinenet.net> wrote:
][ : Yanick Champoux (yanick@babyl.sympatico.ca) wrote:
][ : : That one is a wee bit shorter. But I can't vouch
][ : : for the 'smarter' part. :)
][ : : 
][ : : my %foo = ( key1 => 1, key2 => 1, key3 => 0, key4 => 0 );
][ : : 
][ : : my $s = ';';
][ : : $s = $foo{$_}?"$_,$s":"$s,$_" for keys %foo;
][ : : $s =~ s/,?;,?/;/;
][ : : 
][ : : print $s;
][ 
][ : Nice.  Or how about:
][ 
][ : @a=grep{$foo{$_}}keys%foo;
][ : delete@foo{@a};
][ : print join';',map{join',',@$_}[keys%foo],\@a;
][ 
][ Cool. But still, mine is a wee bit shorter. ;) 
][ Although not as short as the one proposed by Rick Delaney. :(
][ 
][ 
][ # Rick Delaney (58chr)
][ @0,@1;push@{$foo{$_}},$_ for keys%foo;$"=",";print"@1;@0";

This one has the same length, but doesn't issue warnings:

   push@{$foo{$_}},$_ for keys%foo;eval'$"=",";print"@1;@0"';


Abigail
-- 
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))


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

Date: 7 Sep 2000 20:29:35 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Small golf problem
Message-Id: <8p9fdv$dck$1@provolone.cs.utexas.edu>

In article <mpWt5.1188$WD3.40232@news20.bellglobal.com>,
Yanick Champoux  <yanick1@sympatico.ca> wrote:
>What would be nice would be a new pragma, 'use golf' that
>would alias all those loooooong function names to something
>a wee bit shorter. Something like 'push @a, sort reverse @b for @c'
>would become 'p@a,s r@b f @c'. A kind of evil counterpart to
>'use english'. :)

Well, "use golf;" is 9 characters, so it might hurt more than it helps
in many cases.

But hey, if you implement it, why not make it do that *and* run the
decompression algorithm used in bunzip2 on the source file?  I mean,
the purpose of Perl golf is to save characters[1] and to be clever, and
what could be more clever than doing the bzip2 algorithm in your head?

  - Logan

[1]  Not strokes -- if it were strokes, "%" would count twice as much
     as "5" because one requires the shift key and other doesn't.


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

Date: Fri, 08 Sep 2000 02:23:03 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Small golf problem
Message-Id: <39B85006.E71C7E98@home.com>


Abigail wrote:
> 
> ][ @0,@1;push@{$foo{$_}},$_ for keys%foo;$"=",";print"@1;@0";
> 
> This one has the same length, but doesn't issue warnings:
> 
>    push@{$foo{$_}},$_ for keys%foo;eval'$"=",";print"@1;@0"';

One char less, also no warnings:

    $a[1-$foo{$_}].="$_," for keys%foo;chop@a;$,=";";print@a;

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Fri, 08 Sep 2000 02:44:57 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Small golf problem
Message-Id: <39B85528.860D8091@home.com>


Rick Delaney wrote:
> 
> Abigail wrote:
> >
> >    push@{$foo{$_}},$_ for keys%foo;eval'$"=",";print"@1;@0"';
> 
> One char less, also no warnings:
> 
>     $a[1-$foo{$_}].="$_," for keys%foo;chop@a;$,=";";print@a;

Just noticed that written this way, the space after "$_," can be
squeezed out.  But then, this may not do what's desired if there are no
1's or no 0's.  Ok, I'll stop now.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Fri, 08 Sep 2000 02:50:02 GMT
From: Yanick Champoux <yanick@babyl.sympatico.ca>
Subject: Re: Small golf problem
Message-Id: <utYt5.244469$1h3.4568727@news20.bellglobal.com>

Logan Shaw <logan@cs.utexas.edu> wrote:
: In article <mpWt5.1188$WD3.40232@news20.bellglobal.com>,
: Yanick Champoux  <yanick1@sympatico.ca> wrote:
:>What would be nice would be a new pragma, 'use golf' that
:>would alias all those loooooong function names to something
:>a wee bit shorter. Something like 'push @a, sort reverse @b for @c'
:>would become 'p@a,s r@b f @c'. A kind of evil counterpart to
:>'use english'. :)

: Well, "use golf;" is 9 characters, so it might hurt more than it helps
: in many cases.

It could be implicit to any script of less than 30 characters and 
generating more than 15 warnings (or having a \s:\S ratio of less 
than 1:20). :)

: But hey, if you implement it, why not make it do that *and* run the
: decompression algorithm used in bunzip2 on the source file?  I mean,
: the purpose of Perl golf is to save characters[1] and to be clever, and
: what could be more clever than doing the bzip2 algorithm in your head?

Strangely, clever is not the first adjective I would be tempted 
to use to describe someone bunzip2'ing in his/her head. :)

/Yanick

-- 
$,=' '; $\="\n"; @_= qw/a a a a/; @s= qw/17049 482466755 285075 95568295/;
while( (sort @s)[-1] ){ map $s[$_]-->0&&++$_[$_], (0..$#_); print @_; } 
                    ### May take some time. :) ###


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

Date: 08 Sep 2000 02:50:18 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Small golf problem
Message-Id: <slrn8rgktf.vlt.abigail@alexandra.foad.org>

Rick Delaney (rick.delaney@home.com) wrote on MMDLXV September MCMXCIII
in <URL:news:39B85006.E71C7E98@home.com>:
<> 
<> Abigail wrote:
<> > 
<> > ][ @0,@1;push@{$foo{$_}},$_ for keys%foo;$"=",";print"@1;@0";
<> > 
<> > This one has the same length, but doesn't issue warnings:
<> > 
<> >    push@{$foo{$_}},$_ for keys%foo;eval'$"=",";print"@1;@0"';
<> 
<> One char less, also no warnings:
<> 
<>     $a[1-$foo{$_}].="$_," for keys%foo;chop@a;$,=";";print@a;

Two chars less than that:
  
       $a[!$foo{$_}].="$_,"for keys%foo;chop@a;$,=";";print@a;


Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


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

Date: 08 Sep 2000 01:44:42 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Sorting again.
Message-Id: <slrn8rgh2g.vlt.abigail@alexandra.foad.org>

Logan Shaw (logan@cs.utexas.edu) wrote on MMDLXV September MCMXCIII in
<URL:news:8p9dgq$cvk$1@provolone.cs.utexas.edu>:
|| 
|| Has anyone thought about just incorporating several sorts into the Perl
|| distribution as loadable modules?

Yes. Perhaps in 5.7.x, for some x.



Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


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

Date: 8 Sep 2000 01:32:40 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: Stable sorting
Message-Id: <968376758.434938@elaine.furryape.com>

In article <1c7frssd63dg2qs3vpk0ft8nqflh7d4vgp@4ax.com>,
Bart Lateur  <bart.lateur@skynet.be> wrote:
>I think he wants an option for a faster algorithm, that isn't
>necessarily stable.
>
>Or is merge sort the fastest sort around?

There is no single 'fastest sort'. It depends on your data.

Some algorythms are efficent for unsorted data, but have poor results
on sorted or nearly sorted data. Some behave the opposite.

Some algorythms are efficent for small data sets, but as the data
set grows larger, grow less and less efficent. Others have poor
behaviour with small data sets, but grow less efficent slower, so
achieve better results with large datasets.

As an extreme case, if your data is already sorted, then the fastest
sort is a simple copy. Doesn't work too well if the data isn't sorted.

If you want to have the best possible performance, then you should
be reading Knuth, Art of Computer Programming, Volume 3, and choose an
appropriate algorythm for your data. Of course, you probably shouldn't
be programming in perl, any efficencies you save by selecting the
sort will be lost by the speed of perl compared to the built in
sort.


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

Date: 08 Sep 2000 01:52:48 GMT
From: abigail@foad.org (Abigail)
Subject: Re: The Heartbreak of Inscrutable Perl Code
Message-Id: <slrn8rghhl.vlt.abigail@alexandra.foad.org>

Avast (avast@hortonsbay.com) wrote on MMDLXV September MCMXCIII in
<URL:news:39b83211.32895141@news.accesstoledo.com>:
__ 
__ Yeah, but the JAPHs are fun to run.  I especially like the one of
__ Abigail's that prints "Just Another Perl Hacker" backwards and then
__ reverses it slowly letter by letter.  Pretty cool!


Never wrote such a one. I think you are confused with the one that performs
a bubble sort to put the letters in the correct position. ;-)



Abigail
-- 
$=-=4*++$|;{print$"x--$==>"\@\x7Fy~*kde~box*Zoxf*Bkiaox \r"
                            ^
$/x24if!select$,,$,,$,,join+q=.==>$^W=>$|;$=&&redo}sleep$|;


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

Date: Fri, 8 Sep 2000 01:46:09 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: two questions- help
Message-Id: <slrn8rgh6u.9f5.efflandt@efflandt.xnet.com>

On Thu, 07 Sep 2000, interlocator@my-deja.com <interlocator@my-deja.com> wrote:
>I'm not lazy, I'm studying but don't know the words to be able to find
>these answers so I'll just describe my questions.
>
>I need to pass the "user" from one script to another script for further
>processing.
>
>And,
>
>I want to send two emails to the same person, one that has a thank you,
>and a separate one that has the password.  I can send one email using
>sendmail, but when I try to send another right after it it errs.

Are you closing the filehandle used for sendmail before attempting to
reopen it?

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Fri, 08 Sep 2000 02:24:18 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: use strict: why?
Message-Id: <m5Yt5.13282$a5.191468@news1.rdc1.mb.home.com>

In article <slrn8rgd6f.26k.tim@degree.ath.cx>,
 Tim Hammerquist <tim@degree.ath.cx> wrote:
[snip]
> I never asked why people recommend it. Especially in a newsgroup like 
> this, it's use is obvious.  I asked why it's absence in a script is
> labeled as an error.

Actually, you didn't ask why the absence of 'strict' is labelled
as an error (on this group) -- in fact, looking over your original
post, I fail to see where you actually ask anything at all.

What you did do was state that 'use strict' is 'encouraged much like
a dealer pushes drugs' -- which seems a rather negative connotation
to say the least. The main thrust of your article seems merely to be
an accusation that this NG pushes 'strict' too much when it should be
only a guideline, not a hard and fast rule. Yet, in your response to
me you agree 'very much so' on the value of pushing 'strict' on this
NG, and say that here its use is obvious. But now you change your
position and ask why the lack of 'strict' is labelled as an error.

Sure 'strict' is not required in every Perl program, it wasn't even
in version 4, so using it is certainly  not an absolute rule of the
language. Nobody, at least none that I've read, say that lack of
'strict' is an error (in terms of a program's correctness). However,
many appear to feel, and thus an implicit rule seems to have evolved
here, that posting code on this NG -- where it will be seen, and
perhaps emulated, by large numbers of neophytes -- without using
'strict' and -w (and consistent style, and reasonable identifier
names, and other sound guidelines as appropriate) is indeed an error,
and its absence will very likely be commented on and/or corrected.

And, like any good rule, there are always exceptions (one-liners,
cool tricks, japh's, other obfuscated tidbits, golf, etc.).

regards,
andrew

-- 
Andrew L. Johnson   http://members.home.net/andrew-johnson/
      A closed mouth gathers no foot.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4255
**************************************


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