[16108] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3520 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 30 06:05:37 2000

Date: Fri, 30 Jun 2000 03:05:19 -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: <962359519-v9-i3520@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 30 Jun 2000     Volume: 9 Number: 3520

Today's topics:
    Re: $$$$$ username <gellyfish@gellyfish.com>
    Re: $_ and @_ use? (Tad McClellan)
    Re: 2nd level of reference <gellyfish@gellyfish.com>
    Re: 2nd level of reference <gellyfish@gellyfish.com>
    Re: a large amount of unique numbers in an efficient wa <arnet@hpcvplnx.cv.hp.com>
    Re: a large amount of unique numbers in an efficient wa (Bernard El-Hagin)
    Re: a large amount of unique numbers in an efficient wa (Neil Kandalgaonkar)
    Re: a large amount of unique numbers in an efficient wa (Abigail)
    Re: Arrakis & Perl (Rafael Garcia-Suarez)
        change in precedence from 5.00503 -> 5.6.0 ? (Neil Kandalgaonkar)
        Changing .htpasswd on the fly.. <hans@exonet.net>
        check for valid e-mail address <mike.solomon@eps.ltd.uk>
        DBI and interpolation (Prasanth A. Kumar)
    Re: DBI and interpolation (Rafael Garcia-Suarez)
    Re: deleting entries in a hash <paulo@xilinx.com>
    Re: Extract parts of a Mime mail ... <gellyfish@gellyfish.com>
        Finding FatalsToEmail ? <jtjuslin@kosh.hut.fi>
    Re: Finding out free disk space ??? <Roger.Tillmann@extern.rwso.de>
    Re: Forced Authentication <gellyfish@gellyfish.com>
    Re: Golf problem (Bernard El-Hagin)
    Re: Golf problem (Neil Kandalgaonkar)
    Re: Golf problem <hump@katz.cc.univie.ac.at>
    Re: Golf problem (Abigail)
    Re: hopdelta program? <gellyfish@gellyfish.com>
    Re: Hot swap modules without shutdown <Peter.Dintelmann@dresdner-bank.com>
    Re: How to get the PID of a process startet by system() <herz.s@zdf.de>
        How to open another browser in Perl? <chenshaohong@sim.edu.sg>
    Re: How to open another browser in Perl? (Rafael Garcia-Suarez)
    Re: HTML::Parser docs and homepage <gellyfish@gellyfish.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 30 Jun 2000 09:59:08 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: $$$$$ username
Message-Id: <8jhngs$gtc$1@orpheus.gellyfish.com>

On Wed, 28 Jun 2000 12:18:21 -0700 /$username/ wrote:
> How do you check for/parse special PERL characters like $,@,% from FORM
> fields on a POST.
> 
> For example,
> if $_ = "a$b$c$d"
> 
> and i do this..
> 
>  $_=~s/\x24/""/eg; #-- Tried "$" and variations instead of \x24
> 
> I should get this;
> 
> $_="abcd"
> 

s/\$//g;

or probably more efficiently:

tr/$//d;

As Larry Rosler appears to have been kidnapped by aliens ...

> But I don't..
> 
> Application;
> 
> I'm checking fields on a FORM.
> When the client enters $$$$$ as username, it totally wreaks havoc if not
> creating error.
> 

Generally speaking it is better to check for the allowable values than for
the ones you dont want as you are highly likely to omit the check for
something crucial in the latter case whilst having a false sense of
security.

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: Thu, 29 Jun 2000 23:46:57 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: $_ and @_ use?
Message-Id: <slrn8lo61h.59f.tadmc@magna.metronet.com>

On Thu, 29 Jun 2000 22:49:09 -0500, Jim Kauzlarich <o1technospam@skyenet.nospam.net> wrote:


>What is "Perl golf"?  I assume it has something to do with randomly hacking
>your way to the goal.  I've heard the term at least twice now and I'm
>curious.


Accomplishing some task in Perl with the fewest possible characters.

"lower score is better", like in golf.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 30 Jun 2000 09:13:12 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: 2nd level of reference
Message-Id: <8jhkqo$82u$1@orpheus.gellyfish.com>

On Thu, 29 Jun 2000 16:13:02 GMT perl_monkey@my-deja.com wrote:
> In article <sa8hfac1pbf.fsf@sun_tong_001.personal.yahoo.com>,
>   Tong <suntong001@yahoo.com> wrote:
>> Hi,
>>
>> Let me ask my question by giving an example:
>>
>> I used to use
>>
>> print "[]$url_title\n  $url_addr\n\n  $url_intro\n\n" ;
>>
>> to print my url_... variables. Now that they spread all over my
>> code, I now try to difine a signle variable:
>>
>> my $myformat='[]$url_title\n  $url_addr\n\n  $url_intro\n\n' ;
> 
> Bzzt!  You want:
> 
> my $myformat = "[]$url_title\n $url_addr\n\n $url_intro\n\n";
> 
> I.e., use doublequotes, not single quotes.  The difference is that in
> perl, when you use doublequotes, it interpolates the value of the
> variables.
> 

Bzzt! No he doesnt.  He wants to interpolate the values into the string
whenever $myformat is used not when it is assigned to.

>> 		print "@{[$myformat]}";
> 
> This is wrong.  $myformat isn't any array.  I think what you meant to
> say was @{$myformat} but that wouldn't have worked either.
> 

No. That doesnt imply that $myformat is an array at all.  It is one of
the idioms in the FAQ for interpolating some expression into a double
quoted string - it doesnt work in this case of course but not for the
reason that you think.

As has been mentioned before the answer to the OPs question is in perlfaq4 :

       How can I expand variables in text strings?

but I would recommend that you read the *whole* of perlfaq4.

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: 30 Jun 2000 09:04:41 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: 2nd level of reference
Message-Id: <8jhkap$6ev$1@orpheus.gellyfish.com>

On Thu, 29 Jun 2000 14:22:31 -0400 Stephen Kloder wrote:
> Colin Watson wrote:
> 
>> Stephen Kloder <stephen.kloder@gtri.gatech.edu> wrote:
>> >* Tong * wrote:
>> >> my $myformat='[]$url_title\n  $url_addr\n\n  $url_intro\n\n' ;
>> >
>> >The problem is, as soon as you declare $myformat, it contains the values
>> >of the interpolated variables at that time, and cannot update.
>>
>> If you read the code a little more closely, those are single quotes ...
>>
> 
> I saw that.  I figured that the problem was printing updated variables
> without retyping the string.  Since his post stated that he was printing in
> many different places, I presumed variables were likely to change between
> prints.
> 

Yes but the variables arent interpolated into that string ...

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: 30 Jun 2000 06:22:34 GMT
From: <arnet@hpcvplnx.cv.hp.com>
Subject: Re: a large amount of unique numbers in an efficient way?
Message-Id: <8jheba$rcs$1@hpcvnews.cv.hp.com>

In comp.lang.perl Abigail <abigail@delanet.com> wrote:


> Part of being an correct algorithm implies garanteed termination.
> The above algorithm doesn't have that.

Assuming that the random number generator was truely random, how could
you *ever* guarantee termination?  The sequence "1047 1047 1047 1047 ..."
is as random as any other.  Is there a way to generate x *unique*
random numbers between y and z and guarantee that you will always terminate?

Somehow I think this is a lot deeper issue than it might appear at
first, but then again, it is late...

--arne

DISCLAIMER:  These opinions and statements are those of the author and
do not represent any views or positions of the Hewlett-Packard Co.

> Abigail
> -- 
> perl  -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
>           for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
>           print chr 0x$& and q
>           qq}*excess********}'


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

Date: Fri, 30 Jun 2000 06:34:32 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: a large amount of unique numbers in an efficient way?
Message-Id: <slrn8lofjh.mm6.bernard.el-hagin@gdndev25.lido-tech>

On 29 Jun 2000 22:14:46 EDT, Abigail <abigail@delanet.com> wrote:
>Abigail
>-- 
>perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT

Can someone please explain how this works?

Bernard
--
perl -wle '$_=q badqm!qcb;for(split ??){++$_;s g1gqq+a+ge;print}'


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

Date: Fri, 30 Jun 2000 08:39:04 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: Re: a large amount of unique numbers in an efficient way?
Message-Id: <8jhlup$ebi$1@localhost.localdomain>

In article <slrn8lofjh.mm6.bernard.el-hagin@gdndev25.lido-tech>,
Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote:
>On 29 Jun 2000 22:14:46 EDT, Abigail <abigail@delanet.com> wrote:
>>Abigail
>>-- 
>>perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT
>
>Can someone please explain how this works?

The -e commands don't have to be quoted, the shell will pass them on
when properly escaped.

Multiple -e commands build up a multi-line script. So the script is:

print <<EOT;
Just
another
Perl
Hacker
EOT

which should not be mystifying, it's a heredoc. See man perldata.

the behaviour of -e, and all the other switches, is explained in man 
perlrun.

This one is a mere trifle by Abigail standards.

-- 
Neil Kandalgaonkar <neil@brevity.org>


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

Date: 30 Jun 2000 05:04:51 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: a large amount of unique numbers in an efficient way?
Message-Id: <slrn8lopnb.r4j.abigail@alexandra.delanet.com>

arnet@hpcvplnx.cv.hp.com (arnet@hpcvplnx.cv.hp.com) wrote on MMCDXCV
September MCMXCIII in <URL:news:8jheba$rcs$1@hpcvnews.cv.hp.com>:
** In comp.lang.perl Abigail <abigail@delanet.com> wrote:
** 
** > Part of being an correct algorithm implies garanteed termination.
** > The above algorithm doesn't have that.
** 
** Assuming that the random number generator was truely random, how could
** you *ever* guarantee termination?  The sequence "1047 1047 1047 1047 ..."
** is as random as any other.  Is there a way to generate x *unique*
** random numbers between y and z and guarantee that you will always terminate?

Of course, and even in time O (x) if you assume that hash access is
done in O (1) time.

** Somehow I think this is a lot deeper issue than it might appear at
** first, but then again, it is late...

It's elementary. A beginners assignment.


    # Select $amount unique values between $min and $max (inclusive).
    sub sel {
        my ($min, $max, $amount) = @_;

        die "Impossible" if $amount > $max - $min + 1;

        my @results;
    
        my $last = $max;
        my %map;
        for (1 .. $amount) {
            my $rand = $min + int rand ($last - $min + 1);
            push @results => exists $map {$rand} ? $map {$rand} : $rand;
            $map {$rand}  =  exists $map {$last} ? $map {$last} : $last;
            $last --;
        }

        @results
    }


(This is just a Fisher Yates shuffle in disguise)


Abigail
-- 
perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'


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

Date: Fri, 30 Jun 2000 07:18:30 GMT
From: garcia_suarez@hotmail.com (Rafael Garcia-Suarez)
Subject: Re: Arrakis & Perl
Message-Id: <slrn8loim4.p62.garcia_suarez@rafael.kazibao.net>

news.teleline.es wrote in comp.lang.perl.misc:
>Hello,
>now Arrakis.com don't allow Perl cgi for all the new users.

They're probably afraid that someone could code a giant internet worm.

-- 
Rafael Garcia-Suarez


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

Date: Fri, 30 Jun 2000 09:47:07 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: change in precedence from 5.00503 -> 5.6.0 ?
Message-Id: <8jhpue$ehm$1@localhost.localdomain>


[ Sorry about the subject-less posting. My news config is messed up so
I couldn't cancel that. ]


In article <slrn8lopmr.poj.garcia_suarez@rafael.kazibao.net>,
Rafael Garcia-Suarez <garcia_suarez@hotmail.com> wrote:

>What is your perl version? It seems that the parser has evolved since
>5.00503.

I'm using 5.6.0. Funny, I had a sneaking suspicion about this, but I 
thought there was no way operator precedence had changed.


$ perl5.00503 -MO=Deparse,-p -e '  not($a) &&  not($b) ' 2>&-
(not ($a && (!$b)));

$ perl5.6.0   -MO=Deparse,-p -e '  not($a) &&  not($b) ' 2>&-
((not $a) and (not $b));


Shame on me for not checking.

So, is this a bug or a feature? I don't see anything in perldelta.


-- 
Neil Kandalgaonkar <neil@brevity.org>


-- 
Neil Kandalgaonkar <neil@brevity.org>


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

Date: Fri, 30 Jun 2000 11:13:41 +0200
From: Hans <hans@exonet.net>
Subject: Changing .htpasswd on the fly..
Message-Id: <9qoolsgiqjos8flriou1b5ha7neo06cht1@4ax.com>

Hi,

Is there a way to change .htpasswd on the fly from a Perl script?
I have users who must register on my site, and I want to be able to
add a new line to .htpasswd so  the new user can login at once.

Any suggestions?

CU
Hans.

-- 
 EVA <http://www.exonet.net>


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

Date: Fri, 30 Jun 2000 10:48:16 +0100
From: "mike solomon" <mike.solomon@eps.ltd.uk>
Subject: check for valid e-mail address
Message-Id: <8jhqg0$ie20$1@ID-36965.news.cis.dfn.de>

I have written a script to send e-mail from the Unix command line

I test if what looks like a valid address has been entered and if the format
is incorrect I create an error

#test if addresses are valid
#ADD99 is an array containing addresses
for (@ADD99) {
    @ADD_NO99 = split("@") ;
    #test if address contains space or field2 does not contain a "."
    if ( $ADD_NO99[0] =~ / / || length($ADD_NO99[0]) == 0 || $ADD_NO99[1] !~
/\./ ) {
         push @ERROR99 => "INVALID ADDRESS $_";
    }
    #set up valid addresses
    else { $ADD_GOOD99 = "$ADD_GOOD99 $_"; }
}

while it works, I am not overly happy with this test, has anyone written a
better one or is there a module that checks that the format of an e-mail
address is valid

Your help would be appreciated

Regards

Mike Solomon





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

Date: Fri, 30 Jun 2000 09:06:53 GMT
From: kumar1@home.com (Prasanth A. Kumar)
Subject: DBI and interpolation
Message-Id: <m3sntvwn9u.fsf@C654771-a.frmt1.sfba.home.com>


I have a perl script which makes use of DBI to query/update a
database. One problem is that if some the query variables, which are
interpolated into the prepare statement have single quotes in them,
the query fails. So is the proper solution to use '?' in place of the
interpolations and then do bind_param's?

-- 
Prasanth Kumar
kumar1@home.com


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

Date: Fri, 30 Jun 2000 09:15:39 GMT
From: garcia_suarez@hotmail.com (Rafael Garcia-Suarez)
Subject: Re: DBI and interpolation
Message-Id: <slrn8lophq.poj.garcia_suarez@rafael.kazibao.net>

Prasanth A. Kumar wrote in comp.lang.perl.misc:
>
>I have a perl script which makes use of DBI to query/update a
>database. One problem is that if some the query variables, which are
>interpolated into the prepare statement have single quotes in them,
>the query fails. So is the proper solution to use '?' in place of the
>interpolations and then do bind_param's?

Yes. This is one of the many solutions. Another solution is to use
$dbh->quote. Another solution is to use $sth->execute($param1,$param2...)
(that internally calls bind_param). See the DBI manpage.

-- 
Rafael Garcia-Suarez


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

Date: Thu, 29 Jun 2000 20:47:12 -0700
From: Paulo Dutra <paulo@xilinx.com>
Subject: Re: deleting entries in a hash
Message-Id: <395C1840.AF034D7@xilinx.com>

Thanks Bob,


I reviewed it more, and actually I confused the issue. I delete
elements from anonymous array that is clinged to from anonymous hash.

I provided an example. You'll that the copy of hash and it's values
are modified. This in turn modifies the original. How do I avoid it?



#!/group/techsup/perl5.6/bin/perl

#Written by:  Paulo Dutra (paulo@xilinx.com)

# Hash of assigned members listed 
my($assign) = {
              'Team1' => ['rui', 'eddie'],
              'Team2' => ['frog', 'rui'],
};

for (my $n = 1; $n <= 2; ++$n)
  {
  printf ("-- Starting iteration %d\n", $n);
  my(%temp) = %$assign;

  foreach $grp ('Team1', 'Team2')
    {
    my(%saw) = ();
   
    @before_temp = @{ $temp{$grp} };
    @before_orig = @{ $$assign{$grp} };

    print "BEFORE copy of hash: @before_temp\n";
    print "BEFORE original hash: @before_orig\n";

    # Extract the unique elements and reset the members array
    @saw{@{ $temp{$grp} }} = ();
    @{ $temp{$grp} } = ();

    # Delete rui for array of teams
    delete $saw{'rui'} if exists $saw{'rui'};

    push(@{ $temp{$grp} }, keys %saw); 

    @after_temp = @{ $temp{$grp} };
    @after_orig = @{ $$assign{$grp} };

    print "AFTER copy of hash: @after_temp\n";
    print "AFTER original hash: @after_orig\n";
    }
  }

-- 
Paulo                                      //\\\\ 
                                           | ~ ~ |
                                          (  O O  )
 __________________________________oOOo______( )_____oOOo_______
|                                             .                 |
| / 7\'7 Paulo Dutra (paulo@xilinx.com)                         |
| \ \ `  Xilinx                              hotline@xilinx.com |
| / /    2100 Logic Drive                    (800) 255-7778     |  
| \_\/.\ San Jose, California 95124-3450 USA                    | 
|                                                  Oooo         |
|________________________________________oooO______(  )_________|
                                         (  )       ) /
                                          \ (      (_/
                                           \_)


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

Date: 30 Jun 2000 09:38:24 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Extract parts of a Mime mail ...
Message-Id: <8jhma0$cu1$1@orpheus.gellyfish.com>

On Thu, 29 Jun 2000 10:11:49 +0200 morin julien wrote:
> Hello,
> I'd like to know how to extract only the text/plain part of a mail just
> received via a POP3 account ...
> 

Mime-Tools from CPAN .

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: Fri, 30 Jun 2000 09:21:45 +0300
From: Jukka Juslin <jtjuslin@kosh.hut.fi>
Subject: Finding FatalsToEmail ?
Message-Id: <Pine.OSF.4.10.10006300915130.24460-100000@kosh.hut.fi>


Hello,

I heard from Randal L. Schwarz about FatalsToEmail, but could not find it
with altavista or google. Where can I get such a thing?

I guess it's a close relative to the:
use CGI::Carp qw(fatalstoBrowser);
 
Please answer both to the newsgroup and to author via email!

Thanks.

++Jukka;

--
 http://www.hut.fi/u/jtjuslin/

Fuch's Warning:
	If you actually look like your passport photo, you aren't well
enough to travel.



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

Date: Fri, 30 Jun 2000 08:14:19 +0200
From: Roger Tillmann <Roger.Tillmann@extern.rwso.de>
Subject: Re: Finding out free disk space ???
Message-Id: <395C3ABB.C5C083D@extern.rwso.de>

THANX :-))))





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

Date: 30 Jun 2000 10:04:16 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Forced Authentication
Message-Id: <8jhnqg$hsn$1@orpheus.gellyfish.com>

On Wed, 28 Jun 2000 12:25:54 -0700 /$username/ wrote:
> Sorry, I should have included both Qs in same post.
> 
> My ISP only lets me protect directories with .htpasswrd and .htaccess to a
> limited degree.
> I have no <LIMIT> control per domain.
> And so a protected directory will pop up a username/password box.
> I want my scripts POSTed from my URL to be able to forgo the box popup.
> 
> Does anyone know the header string to force authentication and prevent the
> POP-UP password box when I access a protected directory using a POST method?
> 
> I remember something similar from when I programmed CGIs with VB but cannot
> find PERL sample.
> 

That in itself should tell you that it is not a Perl specific thing and
should be asked in comp.infosystems.www.authoring.cgi .

Unless you would like us to read you the perlfunc entry for 'print' of
course.

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: Fri, 30 Jun 2000 06:47:25 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Golf problem
Message-Id: <slrn8logbo.mm6.bernard.el-hagin@gdndev25.lido-tech>

On Fri, 30 Jun 2000 01:17:58 GMT, Craig Berry <cberry@cinenet.net> wrote:
>Peter Marksteiner (hump@katz.cc.univie.ac.at) wrote:
>: Suppose you want to find words with exactly ten non-repeating letters such
>: as "binoculars", "fishmonger", or "paintbrush", suitable for games or simple 
>: encryption of numbers where every decimal digit is represented by a letter.
>: 
>: I've tried to write the shortest possible Perl program to extract
>: such words from a wordlist and have found the following two solutions:
>: 
>: perl -pe '%c=();length==11&!grep{$c{$_}++}split""or$_=""' /usr/dict/words
>: perl -pe '$_=""if(keys%{{map{$_,1}split""}})*length!=121' /usr/dict/words
>: 
>: Is there anybody who can do it with fewer keystrokes?
>
>  perl -pe 'length==11&&\!/(.).*\1/ or$_=""' /usr/dict/words

I renamed my words file to "w" and moved it to /tmp to get 9 strokes
less:

perl -pe 'length==11&&\!/(.).*\1/ or$_=""' /tmp/w

Just kidding.

Bernard
--
perl -wle '$_=q badqm!qcb;for(split ??){++$_;s g1gqq+a+ge;print}'


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

Date: Fri, 30 Jun 2000 08:17:07 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: Re: Golf problem
Message-Id: <8jhkli$e89$1@localhost.localdomain>

In article <slnta6pmjev21@corp.supernews.com>,
Craig Berry <cberry@cinenet.net> wrote:
>Peter Marksteiner (hump@katz.cc.univie.ac.at) wrote:
>: Suppose you want to find words with exactly ten non-repeating letters such
>: as "binoculars", "fishmonger", or "paintbrush", suitable for games or simple 
>: encryption of numbers where every decimal digit is represented by a letter.
>
>  perl -pe 'length==11&&!/(.).*\1/ or$_=""' /usr/dict/words


Slightly shorter:

   perl -ne '/^(?!.*(.).*\1).{10}$/&&print' /usr/dict/words



This one isn't shorter, but I found it interesting:

   perl -F// -ape 'my%F;$_=""if@F!=10||(@F{@F}=@F)!=keys%F' /usr/dict/words


-- 
Neil Kandalgaonkar <neil@brevity.org>


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

Date: 30 Jun 2000 08:39:44 GMT
From: Peter Marksteiner <hump@katz.cc.univie.ac.at>
Subject: Re: Golf problem
Message-Id: <8jhmcg$5q0s$1@www.univie.ac.at>

Leo Schalkwyk <schalkwy@minnie.molgen.mpg.de> wrote:
: Jack Applin (neutron@fc.hp.com) wrote:
: :        perl -pe '$_=""if/(.).*\1/||11-length' /usr/dict/words

: that is not only the shortest by far, it's also perfectly readable
: code.  Wins the 'short,sweet,and perlish' prize!

We can save one more stroke by using binary "or":

perl -pe '$_=""if/(.).*\1/|11-length' /usr/dict/words

A "regex only" solution would be longer by one stroke:

perl -pe '$_=""if/(.).*\1/|!/^.{10}$/' /usr/dict/words

Thanks to all the formidable perl hackers, who, starting with my
shockingly suboptimal algorithms, by relocating and scrambling pieces
of code, and using outlandish nightmares of hacks manifestly requiring
decryption, achieved stupefying abridgment and reductions, inexorably and
crushingly destroying my hopes of becoming a golf champion.  That does
neither discourage nor disgruntle me, presumably I can still find work
as a journalist, blacksmith, or fishmonger!

   Peter

-- 
Peter Marksteiner
Vienna University Computer Center


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

Date: 30 Jun 2000 05:08:21 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Golf problem
Message-Id: <slrn8lopu0.r4j.abigail@alexandra.delanet.com>

Bernard El-Hagin (bernard.el-hagin@lido-tech.net) wrote on MMCDXCV
September MCMXCIII in <URL:news:slrn8logbo.mm6.bernard.el-hagin@gdndev25.lido-tech>:
-: 
-: I renamed my words file to "w" and moved it to /tmp to get 9 strokes
-: less:
-: 
-: perl -pe 'length==11&&\!/(.).*\1/ or$_=""' /tmp/w


Then you could have saved another 5 strokes by first cd'ing to /tmp.


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


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

Date: 30 Jun 2000 10:15:24 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: hopdelta program?
Message-Id: <8jhofc$k1c$1@orpheus.gellyfish.com>

On Wed, 28 Jun 2000 14:30:53 -0700 jfrankov wrote:
> Does anyone have a copy of the hopdelta program from the Perl
> Cookbook, pages 87-89? I'd rather not type it in if I don't have
> to!

For future reference I think that all the examples in the book can be
downloaded from somewhere on the O'Reilly web site ...

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: Fri, 30 Jun 2000 11:24:06 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: Hot swap modules without shutdown
Message-Id: <8jhoud$hu01@intranews.dresdnerbank.de>

    Hi,

John Lin schrieb in Nachricht <8jh1dm$j64@netnews.hinet.net>...
>ModelX version 1.0
>Now modify ModelX without shutting down main program
>Press Enter to continue...
>ModelX version 2.0
>Subroutine new redefined at ModelX.pm line 2, <> line 1.
>Subroutine hello redefined at ModelX.pm line 3, <> line 1.
>
>That is, re-require ModelX was achieved.
>
>As for the warning messages, do they mean to warn us
>about anything that could be seriously dangerous?

    they inform you about the fact that perl already compiled
    a subroutine called new() and that you are now overwriting
    it (the second require compiles the code again). Usually
    there should be no problem with this. You can now

    1. disable warnings in your code block with

        local $^W = 0;

    2. "unload" your subroutines.

        delete $INC{ 'ModelX.pm' };    # 'unrequire'
        undef *ModelX::new;                # undefine new()
        undef *ModelX::hello;               # undefine hello()
        require ModelX;                        # load your module again

    Best regards,

        Peter Dintelmann





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

Date: Fri, 30 Jun 2000 10:49:24 +0200
From: Stefan <herz.s@zdf.de>
Subject: Re: How to get the PID of a process startet by system()?
Message-Id: <395C5F14.A740BDAF@zdf.de>



Stefan wrote:

> Hello,
>
> on Sun/Solaris i'm starting java programs with perl scripts.
> ...
> system("java myprogram");
> echo "PID: ?"

Yes, of couse it should be print "...."

>
> ...
>
> How can i get the PID of this java process, not of the script ?
> When i do this with a bash script i can use $!.
>
> Regards
> Stefan

Thanks to all, now i got it by using:

my $pid = fork;
if (not $pid) {
    print "PID = $$ \n";
    exec("$cmd");
}
print "PID = $pid \n";
wait();

Regards Stefan

P.S.
I read the perl docs and perfaq before,
but i got a little bit to puzzled.





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

Date: Fri, 30 Jun 2000 17:24:15 +0800
From: "shaohong" <chenshaohong@sim.edu.sg>
Subject: How to open another browser in Perl?
Message-Id: <8jhoma$5bt$1@newton3.pacific.net.sg>

Hi:

If we want to use a redirect to send the browser to some other URL, a
redirect('http://somewhere.else/') method exists to facilitate this.

Now my problem is that I want to open a new browser to some other URL, the
original URL is still existing in background. If I don't like some other
URL, I just close it and I still can exist in the original URL.

What technology may I use in Perl? Need your help help!!

Many thanks.

shaohong





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

Date: Fri, 30 Jun 2000 09:50:51 GMT
From: garcia_suarez@hotmail.com (Rafael Garcia-Suarez)
Subject: Re: How to open another browser in Perl?
Message-Id: <slrn8lorjq.pvp.garcia_suarez@rafael.kazibao.net>

shaohong wrote in comp.lang.perl.misc:
>Hi:
>
>If we want to use a redirect to send the browser to some other URL, a
>redirect('http://somewhere.else/') method exists to facilitate this.
>
>Now my problem is that I want to open a new browser to some other URL, the
>original URL is still existing in background. If I don't like some other
>URL, I just close it and I still can exist in the original URL.
>
>What technology may I use in Perl? Need your help help!!

This is not a perl question and can't be achieved by perl means. Lookup
some docs about HTML (e.g. www.htmlhelp.com) and about the <a> tag and its
'target' attribute.

-- 
Rafael Garcia-Suarez


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

Date: 30 Jun 2000 09:37:16 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: HTML::Parser docs and homepage
Message-Id: <8jhm7s$cmq$1@orpheus.gellyfish.com>

On Thu, 29 Jun 2000 09:56:46 GMT sm108@hotmail.com wrote:
> 
> I would like to start using the HTML::Parser module for various tasks,
> but I found the documentation a bit "light" for such a complex module.
> I've been all over CPAN, and I've tried to find a reference home page,
> but no joy.
> Does anyone know of good tutorials for the module?

I have a very brief and sometime to be finished page at :

    <http://www.gellyfish.com/htexamples/>

This only deals with version 2 of the module - I have some examples using
version 3 but you can search Deja News for them ....

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

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


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