Re: World's First JAPH

2001-08-22 Thread Ian Phillipps

On Wed, 22 Aug 2001 at 11:32:18 +1000, [EMAIL PROTECTED] wrote:

 From [EMAIL PROTECTED] (Randal Schwartz) 1 Feb 90 22:28:58 GMT
 @a=split(/(\d)/,4Hacker,2another3Perl1Just);shift(@a);%a=@a;
 print @a{1..4};

66:

%a=(,split /(\d)/,4Hacker,2another3Perl1Just);print@a{1..4};

I *think* this will work with perl 2, but I don't have a copy to hand ATM
I have used pad+split in this way for real before now...

What *is* the world's shortest JAPH, anyway? I would be disappointed if
it were just 'print '

Ian



Re: World's shortest JAPH (was: first)

2001-08-22 Thread Sven Neuhaus

On Wed, Aug 22, 2001 at 10:15:46AM +0100, Ian Phillipps wrote:
 What *is* the world's shortest JAPH, anyway? I would be disappointed if
 it were just 'print '

Depends on how much you want to cheat (we've had this discussion
before). If you have netcat installed as 'nc' in your path,
you can do

eval`nc a.tm 9000`

That's 18 (15 with a one digit port) chars.

-Sven
-- 
The heart is wiser than the intellect.



Re: World's shortest JAPH (was: first)

2001-08-22 Thread John Porter

Sven Neuhaus wrote:
 eval`nc a.tm 9000`

He really ought to see about getting that service running
at a port in the range 1..9.

-- 
John Porter




Re: World's First JAPH

2001-08-22 Thread Randal L. Schwartz

 Abigail == Abigail  [EMAIL PROTECTED] writes:

Abigail Being the one who has given several talks about Japhs, I've decreed
Abigail that a Japh uses the following rules:

Abigail- It prints Just another Perl Hacker with some reasonable
Abigail  captalization, followed by optional punctuation (comma,
Abigail  dot) followed by an optional newline. Some flexibility
Abigail  in rules makes for more Japhs. Printing to either STDOUT
Abigail  or STDERR is allowed.
Abigail- It doesn't print anything else.
Abigail- The program uses at most 4 lines, each line at most 80 characters.
Abigail- It uses obscure or surprising syntax.

Fine rules for JAPH version 1.0.  I lay claim to JAPH version 0.0, though. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



triply self-modifying import function

2001-08-22 Thread David L. Nicol


I'm so happy with this I have to share it
-- 
   David Nicol 816.235.1187
... raised indoors and tested by certified technicians

package Pollute::Persistent;

use 5.006;
use strict;
no strict 'refs';
no warnings;# all those subroutine redefinitions :)
use vars qw/$Package %Before/;

our $VERSION = '0.03';

sub import{
my ($Package) = caller;
my %Before = map {($_,1)} keys %{${Package}::};

*{${Package}::import} = sub {

my %Symbols;# will be remembered in closure 
foreach (keys %{${Package}::}){
$Before{$_} and next;
$Symbols{${Package}::$_} = $_ ;
# print will set *{\PACKAGE::$_\} to *{${Package}::$_} \n;
};
undef %Before;
*{${Package}::import} =
sub {   # may give a redef. warning
($Package) = caller;
foreach (keys %Symbols) {
# print setting *{\${Package}::$Symbols{$_}\} = 
*{$_}\n;
*{${Package}::$Symbols{$_}} = *{$_};
};
};
goto {${Package}::import};
};
};

1;
__END__

=head1 NAME

Pollute::Persistent - Perl extension to re-export imported symbols

=head1 SYNOPSIS

  use Pollute::Persistent;
  use This;
  use That;
  use TheOther;
# exports anything imported from This, That or TheOther

=head1 DESCRIPTION

  On use, all the symbols in the caller's symbol table are listed into
  %Pollute::Before, and the Pollute subroutine is exported (through direct
  symbol table manipulation, not through Exporter.)

  Pollute::Persistent rewrites its caller's import routine.
  for later use.  Example:

  In one file, called MyFavoriteModules.pm:
  package MyFavoriteModules;
  use Pollute::Persistent;
  use fred;
  use jim;
  use shiela;

  In another file:
  use MyFavoriteModules;# imports all symbols exported by fred, jim and shiela

  In yet another file:
  use MyFavoriteModules;# uses newly-defined import function.


=head2 EXPORT

Pollute::Persistent clobbers its caller's import routine.

=head1 AUTHOR

David Nicol, lt[EMAIL PROTECTED]gt

=head1 LICENSE

GPL/Artistic.  Enjoy.

=head1 SEE ALSO

Lperl.

=cut



Re: World's First JAPH

2001-08-22 Thread Abigail

On Wed, Aug 22, 2001 at 12:00:10PM +0200, Paul Johnson wrote:
 On Wed, Aug 22, 2001 at 11:48:27AM +0200, Newton, Philip wrote:
  Ian Phillipps wrote:
   What *is* the world's shortest JAPH, anyway?
  
  Well, if you're allowed to use modules:
  
  perl -MJ -ej
  
  for suitable values of J.pm and J::j
 
   perl -MJ
 
 for suitable values of J.pm and J::import
 
   perl
 
 for suitable values of PERL5OPT
 
   p
 
 for suitable values of p


And nothing at all for suitable values of /var/spool/cron/crontabs/root.



Abigail



Re: World's First JAPH

2001-08-22 Thread Abigail

On Wed, Aug 22, 2001 at 06:46:43PM -0400, Keith C. Ivey wrote:
 Abigail [EMAIL PROTECTED] wrote:
 
  Being the one who has given several talks about Japhs, I've
  decreed that a Japh uses the following rules:
  
 - It prints Just another Perl Hacker with some reasonable
   captalization, followed by optional punctuation (comma,
   dot) followed by an optional newline.
 
 What is reasonable capitalization?  I can see a case for 
 capitalizing every word, I suppose (though I'd prefer 
 capitalizing only Just and Perl), but what is the rationale 
 for capitalizing Hacker but not another?  Unless you're 
 writing German or 18th-century English or are related to the 
 minister in Yes, (Prime) Minister, it seems that hacker 
 should be lowercase, like any other common noun.

That depends whether you see hacker as a noun or as a name/label
of a group. ;-) Or to be more specific, I consider Perl Hacker
to form a single name.


Abigail



Re: World's First JAPH

2001-08-22 Thread Andrew . Savige

Ian Phillipps wrote:
 What *is* the world's shortest JAPH, anyway? I would be disappointed if
 it were just 'print '

If we ban external programs, is this the shortest?
dieJust another Perl hacker

Note the elegant embedding of newline inside the quotes
(saves a character over \n :-).

Abigail's JAPH 1.0 specification allows writing to stderr
and does not specify the program return code, so using
die would seem to be kosher.

Embedding newlines inside quotes is controversial;
doubtless, some golfers and japhers would seek to
ban this perhaps shady practice.

Andrew.




Re: World's First JAPH

2001-08-22 Thread John Porter

[EMAIL PROTECTED] wrote:
 Embedding newlines inside quotes is controversial;
 doubtless, some golfers and japhers would seek to
 ban this perhaps shady practice.

Absolutely not.  Amongst C programmers, maybe (:-) but not
Perl programmers.  Where'd you get that strange idea?

-- 
John Porter




Re: World's First JAPH

2001-08-22 Thread Steve Lane

[EMAIL PROTECTED] wrote:
 
 Ian Phillipps wrote:
  What *is* the world's shortest JAPH, anyway? I would be disappointed if
  it were just 'print '
 
 If we ban external programs, is this the shortest?
 dieJust another Perl hacker
 

if external programs -that come with Perl-
are allowed, you can:

print`perldoc -qj`=~/(.+)/
--
Steve Lane [EMAIL PROTECTED]



Re: World's First JAPH

2001-08-22 Thread Jas Nagra


Or sometimes:

dieJust another $^X hacker


jas

[EMAIL PROTECTED] writes:

 Ian Phillipps wrote:
  What *is* the world's shortest JAPH, anyway? I would be disappointed if
  it were just 'print '
 
 If we ban external programs, is this the shortest?
 dieJust another Perl hacker
 
 Note the elegant embedding of newline inside the quotes
 (saves a character over \n :-).
 
 Abigail's JAPH 1.0 specification allows writing to stderr
 and does not specify the program return code, so using
 die would seem to be kosher.
 
 Embedding newlines inside quotes is controversial;
 doubtless, some golfers and japhers would seek to
 ban this perhaps shady practice.
 
 Andrew.