[24722] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6876 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 17 18:35:28 2004

Date: Tue, 17 Aug 2004 15:05:10 -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           Tue, 17 Aug 2004     Volume: 10 Number: 6876

Today's topics:
    Re: ActiveState PPM/PPM3 just hang up for me (Graham)
        Best way to differentiate accounts with one set of scri <invalid@invalid.com>
    Re: Best way to differentiate accounts with one set of  <noreply@gunnar.cc>
    Re: Best way to differentiate accounts with one set of  ctcgag@hotmail.com
        Can I easily automate testing of my cgi using Test::[so <dont@email.me>
    Re: Earthquake forecasting program   Aug. 16, 2004 <ethan@draupnir.gso.saic.com>
        editing perl script through TEXTAREA (anita)
    Re: editing perl script through TEXTAREA <tore@aursand.no>
    Re: editing perl script through TEXTAREA <noreply@gunnar.cc>
    Re: Forcing Array Context (Randal L. Schwartz)
    Re: Forcing Array Context <emschwar@pobox.com>
    Re: Forcing Array Context (Peter Kay)
        Installing Perl in OS/2? (Seymour J.)
    Re: Installing Perl in OS/2? <pweilba@gwdg.de>
    Re: Materializing an indirect sort using only swap <pinyaj@rpi.edu>
    Re: My own handy Pocket Reference notes (please share y (David Filmer)
    Re: My own handy Pocket Reference notes (please share y (David Filmer)
    Re: My own handy Pocket Reference notes (David Filmer)
    Re: My own handy Pocket Reference notes <pinyaj@rpi.edu>
    Re: My own handy Pocket Reference notes <someone@example.com>
    Re: My own handy Pocket Reference notes <matrix_calling@yahoo.dot.com>
    Re: My own handy Pocket Reference notes <notvalid@email.com>
    Re: My own handy Pocket Reference notes (Randal L. Schwartz)
    Re: My own handy Pocket Reference notes <pinyaj@rpi.edu>
    Re: My own handy Pocket Reference notes <pinyaj@rpi.edu>
    Re: My own handy Pocket Reference notes (Anno Siegel)
    Re: Operator for presence of value in list? <geenbestaandadres@lycos.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 17 Aug 2004 20:36:07 GMT
From: graham@nospam.steelworks.org.uk (Graham)
Subject: Re: ActiveState PPM/PPM3 just hang up for me
Message-Id: <412269ad.4059212@news.freenetname.co.uk>

On Sat, 14 Aug 2004 14:37:16 -0600, Scott Bryce
<sbryce@scottbryce.com> wrote:

>Graham wrote:
>
>> I am running Perl 5.8.0 on Windows ME. If I run PPM or PPM3, I can
>> query my installed modules, but if I try to access the repositories on
>> the Internet (eg, typing "search *", it just hangs up. Anybody else
>> had this problem? Anybody know the answer?
>
>I had a similar problem when I installed Perl 5.8 on top of Perl 5.6. 
>The solution was to uninstall Perl, then reinstall Perl 5.8.
>
Thanks Scott, but I am afraid it is not the answer for me: I have only
ever had 5.8 on my PC.
--
Graham Steel: graham@nospam.steelworks.org.uk
Web: http://www.steelworks.org.uk


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

Date: Tue, 17 Aug 2004 18:17:52 GMT
From: "Vinnie Murdico" <invalid@invalid.com>
Subject: Best way to differentiate accounts with one set of scripts?
Message-Id: <kZrUc.11973$Kf4.9580@nwrddc02.gnilink.net>

Hi,

I'm creating a series of Perl scripts that make up an entire web site.
It works fine, but now I'd like to change it such that I can "replicate"
this entire web site for multiple accounts for various customers.

I don't want to make copies of the scripts for each hosted account,
because errors and enhancements will then need to be replicated across
multiple copies -- a maintenance nightmare.

I thought about requiring users to "log in" first, and creating a cookie
that contains their account name.  Then when each script runs, it looks
at the cookie and gets the account name and uses that to set variables
for unique directories and files where that account's data would be
stored, thus giving each account a unique data area.

Is there a better way to do this that doesn't involve using cookies such
that the scripts could determine which user account was in effect when
it was run so it could look at the correct data location for that
account?

Thanks in advance for any ideas...

-- Vinnie




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

Date: Tue, 17 Aug 2004 20:55:43 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Best way to differentiate accounts with one set of scripts?
Message-Id: <2of2jkF9scegU1@uni-berlin.de>

Vinnie Murdico wrote:
> I'm creating a series of Perl scripts that make up an entire web
> site. It works fine, but now I'd like to change it such that I can
> "replicate" this entire web site for multiple accounts for various
> customers.
> 
> I don't want to make copies of the scripts for each hosted account,
> because errors and enhancements will then need to be replicated
> across multiple copies -- a maintenance nightmare.
> 
> I thought about requiring users to "log in" first, and creating a
> cookie that contains their account name.  Then when each script
> runs, it looks at the cookie and gets the account name and uses
> that to set variables for unique directories and files where that
> account's data would be stored, thus giving each account a unique
> data area.
> 
> Is there a better way to do this that doesn't involve using cookies
> such that the scripts could determine which user account was in
> effect when it was run so it could look at the correct data
> location for that account?

I'm assuming that the scripts are running as CGI scripts. Provided
that suEXEC or a CGI wrap is enabled, the home directory can be
grabbed via the getpwuid() function:

     my $homedir = (getpwuid $<)[7];

But how do you ensure that the scripts are accessed via the 'right'
URL? Maybe not a usable idea, after all...

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


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

Date: 17 Aug 2004 19:42:54 GMT
From: ctcgag@hotmail.com
Subject: Re: Best way to differentiate accounts with one set of scripts?
Message-Id: <20040817154254.961$2G@newsreader.com>

"Vinnie Murdico" <invalid@invalid.com> wrote:
> Hi,
>
> I'm creating a series of Perl scripts that make up an entire web site.
> It works fine, but now I'd like to change it such that I can "replicate"
> this entire web site for multiple accounts for various customers.

I think you first need to decide on a security model, then only once you
have done that does it make sense to worry about this type of detail.

> I don't want to make copies of the scripts for each hosted account,
> because errors and enhancements will then need to be replicated across
> multiple copies -- a maintenance nightmare.

Where is the nightmare?

foreach (@foo) {
  system "rm /blah/blah/$_/*.cgi";
  system "cp *.cgi /blah/blah/$_/";
}

I don't see how this solves anything, but I also don't see how it
causes any problems.

> I thought about requiring users to "log in" first, and creating a cookie
> that contains their account name.  Then when each script runs, it looks
> at the cookie and gets the account name and uses that to set variables
> for unique directories and files where that account's data would be
> stored, thus giving each account a unique data area.

Cookies are easy to spoof.  Would your customers be happy with the
fairly low level of security that this would provide?

> Is there a better way to do this that doesn't involve using cookies such
> that the scripts could determine which user account was in effect when
> it was run so it could look at the correct data location for that
> account?

First you need to make the policy decision of how to authenticate users.
Once you have them authenticated, it probably won't be all that hard to do
the rest.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Tue, 17 Aug 2004 17:32:15 -0400
From: SC <dont@email.me>
Subject: Can I easily automate testing of my cgi using Test::[something]?
Message-Id: <41227832_4@news3.prserv.net>

I'd like to automate testing on a current project.  I read 
Test::Tutorial and the related docs by Michael Schwern (Test::Simple and 
Test::More) and everything seems prety clear to me.

The only problem is that all the examples are for testing modules. 
(About which I don't really know anything).  Is there any way I can test 
the output from my cgi scripts as-is using some of these testing tools 
or am I out of luck?

My cgis are fairly simple affairs taking some params, reading from some 
files/DBMs then outputing html.  I'm not doing anything really clever or 
complicated but I find that the number of things I need to test for is 
growing larger than I can easily handle manually.

I'd really appreciate it if anyone has link to a tutorial or howto on 
the subject.


Scot



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

Date: 17 Aug 2004 10:35:07 -0700
From: Ethan Brown <ethan@draupnir.gso.saic.com>
Subject: Re: Earthquake forecasting program   Aug. 16, 2004
Message-Id: <vr8ycdoegk.fsf@draupnir.gso.saic.com>

Earthquakes don't kill people.  Stuff falling on people kills people.  Improving
building codes and adhearing to these codes goes a long way in mitigating loss of
life in seismically active regions.  For example, a 6.0 earthquake in California will
typically result in few, if any, deaths.  The same size earthquake in a third-world
country can result in many deaths.  All due to the nature of building construction.

The goal of short-term prediction (days-hours) using EM data, without significant false
alarms is probably not reasonable.

This whole discussion seems fairly off-topic. (for comp.lang.perl).


--Ethan 



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

Date: 17 Aug 2004 14:03:57 -0700
From: anita1766@yahoo.com (anita)
Subject: editing perl script through TEXTAREA
Message-Id: <1a1fc02.0408171244.3114d5ce@posting.google.com>

Hello
I am trying to get to edit my perl scripts through a form. I'm loading
the perl script into the TEXTAREA, but the browser interprets the
stuff in the edit box. so if it happens to see another </TEXTAREa>
area in the text, it assumes it has found the end of the textarea and
the rest of my script is just spit out on the screen outside of the
textarea.
I can replace the > and < with HTML entities, while displaying and
whenthe user edits the fields, reinterpret the &entity back into > <
before saving.
My question is this- is there anything else I need to interpret before
I save ?
Like all those innumerable special chars in perl ?!

I realize this is strictly not a PERL question but would appreciate
any feedback. Especially if there are already some modules I can use
to do this sort of thing.
Thanks
anita


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

Date: Tue, 17 Aug 2004 23:45:50 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: editing perl script through TEXTAREA
Message-Id: <pan.2004.08.17.21.45.50.15331@aursand.no>

On Tue, 17 Aug 2004 14:03:57 -0700, anita wrote:
> I am trying to get to edit my perl scripts through a form. I'm loading
> the perl script into the TEXTAREA, but the browser interprets the stuff
> in the edit box. so if it happens to see another </TEXTAREa> area in the
> text, it assumes it has found the end of the textarea and the rest of my
> script is just spit out on the screen outside of the textarea.

Check out the HTML::Entities module.  It will let you encode any "special"
characters to HTML.


-- 
Tore Aursand <tore@aursand.no>
"The road to hell is full of good intentions." (Bruce Dickinson)


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

Date: Tue, 17 Aug 2004 23:48:12 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: editing perl script through TEXTAREA
Message-Id: <2ofcniFa0j18U1@uni-berlin.de>

anita wrote:
> I am trying to get to edit my perl scripts through a form. I'm
> loading the perl script into the TEXTAREA, but the browser
> interprets the stuff in the edit box. so if it happens to see
> another </TEXTAREa> area in the text, it assumes it has found the
> end of the textarea and the rest of my script is just spit out on
> the screen outside of the textarea.
> I can replace the > and < with HTML entities, while displaying and 
> whenthe user edits the fields, reinterpret the &entity back into >
> < before saving.

If you save before converting to HTML entities, you don't need to
convert those characters back.

> My question is this- is there anything else I need to interpret
> before I save ?
> Like all those innumerable special chars in perl ?!
> 
> I realize this is strictly not a PERL question but would appreciate
> any feedback. Especially if there are already some modules I can
> use to do this sort of thing.

I'm not sure if there is a *need* to convert any other characters for
this limited purpose. However, this is a function I'm using:

     sub entify {
         my $ref = defined wantarray ? [ @_ ] : \@_;
         for ( grep defined, @$ref )	{
             s/&/&amp;/g;
             s/"/&quot;/g;
             s/</&lt;/g;
             s/>/&gt;/g;
         }
         @$ref > 1 ? @$ref : $$ref[0]
     }

Besides < and > it converts & and ".

There are also modules, of course, such as HTML::Entities, or you can
use the escapeHTML() function in CGI.pm.

HTH

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


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

Date: 17 Aug 2004 10:39:50 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Forcing Array Context
Message-Id: <86oel9y87t.fsf@blue.stonehenge.com>

>>>>> "Peter" == Peter Kay <peterkayatwork@yahoo.com> writes:

Peter> sub do_it ($$@);

Prototypes.  Eliminate.  Crush.  Kill.  Destroy.

Never use prototypes.  Or at least, not until you understand
exactly why I say "never use prototypes". :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <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!


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

Date: Tue, 17 Aug 2004 13:27:25 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Forcing Array Context
Message-Id: <etobrh9h8f6.fsf@wilson.emschwar>

merlyn@stonehenge.com (Randal L. Schwartz) writes:
>>>>>> "Peter" == Peter Kay <peterkayatwork@yahoo.com> writes:
>
> Peter> sub do_it ($$@);
>
> Prototypes.  Eliminate.  Crush.  Kill.  Destroy.
>
> Never use prototypes.  Or at least, not until you understand
> exactly why I say "never use prototypes". :)

I still have to train myself not to use them, after having decided
quite some time back that they were useful.  I've since been convinced
otherwise, but I still have to remind myself that they're not doing
what I think they're doing.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: 17 Aug 2004 14:19:08 -0700
From: peterkayatwork@yahoo.com (Peter Kay)
Subject: Re: Forcing Array Context
Message-Id: <3081c9ae.0408171319.72d1f2bf@posting.google.com>

merlyn@stonehenge.com (Randal L. Schwartz) wrote in message news:<86oel9y87t.fsf@blue.stonehenge.com>...
> >>>>> "Peter" == Peter Kay <peterkayatwork@yahoo.com> writes:
> 
> Peter> sub do_it ($$@);
> 
> Prototypes.  Eliminate.  Crush.  Kill.  Destroy.
> 

Ok, ok, I get the idea!

I was naively hoping Perl would expand the list, push the first two
elements into the two scalars, and continue on its way.  My bad.

Thanks all :-)

--Peter


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

Date: Tue, 17 Aug 2004 15:34:39 -0300
From: "Shmuel (Seymour J.) Metz" <spamtrap@library.lspace.org.invalid>
Subject: Installing Perl in OS/2?
Message-Id: <41225dcf$3$fuzhry+tra$mr2ice@news.patriot.net>

I want to install Perl in an OS/2 system, and can't find any
installation instructions. I've got the following files, but don't
know what to do with them:

 CHECKSUMS
 latest.tar.gz
 OpenGL-0.4-bin-00-os2.zip
 PERL_AOU.ZIP
 PERL_BLB.ZIP
 PERL_EXC.ZIP
 PERL_INF.ZIP
 PERL_MAM.ZIP
 PERL_MAN.ZIP
 PERL_MLB.ZIP
 PERL_POD.ZIP
 PERL_SH.ZIP
 PERL_STE.ZIP
 PERL_UTL.ZIP
 plINSTAL.zip
 PLINSTL0.ZIP
 plREADME.zip
 stable.tar.gz

PLINSTL0.ZIP contains install.exe install.in_, but doesn't seem to be
self contain. It seems clear that I am supposed to unzip some of the
other files, but it is not clear whether the install utility will
unzip some, or whether I need to unzip all. It is also not clear
whether I need to unzip the files into a temporary directory for the
use of install, or whether I need to unzip them into the run-time
directories.

A second issue is the dates. The files from  CPAN are dated 1998. Is
that really the last stable Perl release for OS/2?

Finally, should I be using the tar.gz files rather than the zip files?
If so, what is the proper command to unpack them. Note that while OS/2
does not come with tar or gzip, they are available as part of EMX.

Thanks.

-- 
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 spamtrap@library.lspace.org



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

Date: 17 Aug 2004 21:23:34 GMT
From: "Peter Weilbacher" <pweilba@gwdg.de>
Subject: Re: Installing Perl in OS/2?
Message-Id: <F3cu0n62uTsd-pn2-b6QpFZrVUdCG@gaston.Weilbacher.org>

On Tue, 17 Aug 2004 18:34:39 UTC, "Shmuel (Seymour J.) Metz" wrote:

> I want to install Perl in an OS/2 system, and can't find any
> installation instructions. I've got the following files, but don't
> know what to do with them:

The file whose name contains README could be of help perhaps? ;-)

>  plREADME.zip

> A second issue is the dates. The files from  CPAN are dated 1998. Is
> that really the last stable Perl release for OS/2?

I would use the one from 
<http://www.cpan.org/authors/id/I/IL/ILYAZ/os2/582+/>, the file 
README.1st is what you should read first...
Don't know why Ilya does not put that into the main ports/os2 directory,
it works fine here since beginning of the year. Perhaps he reads this 
and enlightens us?
-- 
Greetings,                         Please reply in newsgroup, I rarely
   Peter.                            read emails to pweilba@gwdg.de...


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

Date: Tue, 17 Aug 2004 12:08:23 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: Materializing an indirect sort using only swap
Message-Id: <Pine.SGI.3.96.1040817120303.1337262A-100000@vcmr-64.server.rpi.edu>

On 16 Aug 2004 ctcgag@hotmail.com wrote:

>Jeff 'japhy' Pinyan <pinyaj@rpi.edu> wrote:
>
>>   my @array = qw( this little piggie went to market );
>>   my @order = qw( 3 5 1 2 0 4 );
>>   my @new = multi_swap(\@array, \@order);
>>   # expect: (went market little piggie this to)
>>
>> Where the multi_swap() function applies a series of swap()s... is that
>> right?  If so, let me know... I think I can work up an algorithm.
>
>Yes, precisely correct.

Sorry this took so damn long.  I couldn't figure out where I was going
wrong until I realized I needed two additional arrays, not just one:

  # use like so:
  multi_swap($the_object, \@new_indices);  

  sub multi_swap {
    my ($object, $o) = @_;
    my @P = my @R = 0 .. $#$o;
                                                                                
    for (0 .. $#$o) {
      next if $P[$$o[$_]] == $_;
      swap($object, $P[$$o[$_]], $_);
      (@P[$R[$_],  $$o[$_]], @R[$P[$$o[$_]], $_         ]) =
      (@P[$$o[$_], $R[$_] ], @R[$_,          $P[$$o[$_]]]);
    }
  }

  # replace this as you see fit
  sub swap {
    my ($a, $x, $y) = @_;
    @$a[$x,$y] = @$a[$y,$x];
  }

I think I can explain the algorithm, but it's a bitch.  It does it in one
pass, making it O(N).

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
RPI Corporation Secretary   %  have long ago been overpaid?
http://japhy.perlmonk.org/  %  
http://www.perlmonks.org/   %    -- Meister Eckhart








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

Date: 17 Aug 2004 09:11:56 -0700
From: IneverReadAnythingSentToMe@hotmail.com (David Filmer)
Subject: Re: My own handy Pocket Reference notes (please share your own also)
Message-Id: <e4c916dd.0408170604.5d71cf49@posting.google.com>

Thank you to everyone who provided input for this. I have posted a
revised and corrected version of these notes in a new thread:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=e4c916dd.0408161545.4dd376ac%40posting.google.com


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

Date: 17 Aug 2004 09:21:01 -0700
From: IneverReadAnythingSentToMe@hotmail.com (David Filmer)
Subject: Re: My own handy Pocket Reference notes (please share your own also)
Message-Id: <e4c916dd.0408170634.680e2e83@posting.google.com>

Thank you to everyone who provided input for this. I have posted a
revised and corrected version of these notes in a new thread:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=e4c916dd.0408161545.4dd376ac%40posting.google.com


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

Date: 17 Aug 2004 09:11:41 -0700
From: IneverReadAnythingSentToMe@hotmail.com (David Filmer)
Subject: Re: My own handy Pocket Reference notes
Message-Id: <e4c916dd.0408170602.7502ca45@posting.google.com>

Ala> I find this a bit more amusing, although less maintainable:
Ala> 
Ala> 	$var = [$b => $a] -> [$b <= $a];

Yes, very amusing! I've never seen syntax like that before. Would you
be so kind as to explain this?


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

Date: Tue, 17 Aug 2004 12:21:07 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: My own handy Pocket Reference notes
Message-Id: <Pine.SGI.3.96.1040817121812.1337355A-100000@vcmr-64.server.rpi.edu>

On 17 Aug 2004, David Filmer wrote:

>Ala> 	$var = [$b => $a] -> [$b <= $a];
>
>Yes, very amusing! I've never seen syntax like that before. Would you
>be so kind as to explain this?

[$b => $a] is an array reference with two elements, $a and $b.  The => is
nothing more than a comma.

  $var = [$b,$a]->[$b <= $a];

[$b,$a]->[...] is taking an element FROM that array reference.  This could
be written, in this case, as a list and a list slice:

  ($b,$a)[...]

The contents of the slice are '$b <= $a', which is a comparison
expression, "$b less-than-or-equal-to $a".  This comparison returns 1 if
$b is less than or equal to $a, and '' (which is as good as 0 here) if $b
is greater than $a.

($b,$a)[1] returns $a, and ($b,$a)[0] returns $b.  So, if $a is greater
than $b, $a is returned; if $b is greater than $a, $b is returned.  This
is a nearly palindromic max() expression.

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
RPI Corporation Secretary   %  have long ago been overpaid?
http://japhy.perlmonk.org/  %  
http://www.perlmonks.org/   %    -- Meister Eckhart




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

Date: Tue, 17 Aug 2004 16:31:54 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: My own handy Pocket Reference notes
Message-Id: <_pqUc.21781$X12.13991@edtnps84>

David Filmer wrote:
> Ala> I find this a bit more amusing, although less maintainable:
> Ala> 
> Ala> 	$var = [$b => $a] -> [$b <= $a];
> 
> Yes, very amusing! I've never seen syntax like that before. Would you
> be so kind as to explain this?

It's very simple.  :-)   You have a list with two elements ( $b, $a )
and you use a list slice to pick the correct one so when $b <= $a you
get ( $b, $a )[ 1 ] and when $b > $a you get ( $b, $a )[ 0 ].  Then
you throw in an anonymous array and dereference it and you get either
[ $b, $a ]->[ 1 ] or [ $b, $a ]->[ 0 ].


John
-- 
use Perl;
program
fulfillment


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

Date: Tue, 17 Aug 2004 22:16:14 +0530
From: Abhinav <matrix_calling@yahoo.dot.com>
Subject: Re: My own handy Pocket Reference notes
Message-Id: <iKqUc.37$fi5.117@news.oracle.com>

John W. Krahn wrote:

> David Filmer wrote:
> 
>>Ala> I find this a bit more amusing, although less maintainable:
>>Ala> 
>>Ala> 	$var = [$b => $a] -> [$b <= $a];
>>
>>Yes, very amusing! I've never seen syntax like that before. Would you
>>be so kind as to explain this?
> 
> 
> It's very simple.  :-)   

So it is .. once Its been explained :)

<OT>
Sherlock Holmes was always upset that Dr. Watson used to be initially 
amazed at his deductions, but once he explained it, Dr Watson found them 
outrageously "elementary" :)
</OT>

--

Abhinav


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

Date: Tue, 17 Aug 2004 17:25:18 GMT
From: Ala Qumsieh <notvalid@email.com>
Subject: Re: My own handy Pocket Reference notes
Message-Id: <2crUc.5239$Qy4.100@newssvr27.news.prodigy.com>

Jeff 'japhy' Pinyan wrote:

> This is a nearly palindromic max() expression.

I tried hard to make symmetric, to no avail. min() is palindromic though:

	[$a => $b] -> [$b <= $a]

--Ala


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

Date: 17 Aug 2004 10:38:25 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: My own handy Pocket Reference notes
Message-Id: <86smaly8a6.fsf@blue.stonehenge.com>

>>>>> "Ala" == Ala Qumsieh <notvalid@email.com> writes:

Ala> David Filmer wrote:
>> To set a variable to the greater (larger) of two choices:
>> $var = ($a > $b) ? $a : $b;

Ala> I find this a bit more amusing, although less maintainable:

Ala> 	$var = [$b => $a] -> [$b <= $a];

And more expensive.  All the work to create an anonymous list, then an
anonymous array from that, take a reference to it, dereference it, and
then pull one of the two items back out, and then discard the array
and the list value.

Ugh.

Please shoot the person who came up with that cute hack.  That's
just as cutesey (and dangerous) as rename $x => $y.  Ugh.

print "Just another Perl hacker,"; 

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <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!


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

Date: Tue, 17 Aug 2004 17:01:32 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: My own handy Pocket Reference notes
Message-Id: <Pine.SGI.3.96.1040817170005.1340076A-100000@vcmr-64.server.rpi.edu>

On Tue, 17 Aug 2004, Ala Qumsieh wrote:

>Jeff 'japhy' Pinyan wrote:
>
>> This is a nearly palindromic max() expression.
>
>I tried hard to make symmetric, to no avail. min() is palindromic though:
>
>	[$a => $b] -> [$b <= $a]

Well, that's only palindromic if $a, $b, and -> are taken as individual
symbols, and if you let mirror image characters be palindromic of their
original.

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
RPI Corporation Secretary   %  have long ago been overpaid?
http://japhy.perlmonk.org/  %  
http://www.perlmonks.org/   %    -- Meister Eckhart




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

Date: Tue, 17 Aug 2004 17:02:30 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: My own handy Pocket Reference notes
Message-Id: <Pine.SGI.3.96.1040817170135.1340076B-100000@vcmr-64.server.rpi.edu>

On 17 Aug 2004, Randal L. Schwartz wrote:

>Please shoot the person who came up with that cute hack.  That's
>just as cutesey (and dangerous) as rename $x => $y.  Ugh.

What, specifically, is dangerous about

  rename $x => $y;

Apart from a lack of error-checking, I mean.  I thought that was a rather
clever use of the => comma to signify a "becoming" relationship.

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
RPI Corporation Secretary   %  have long ago been overpaid?
http://japhy.perlmonk.org/  %  
http://www.perlmonks.org/   %    -- Meister Eckhart




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

Date: 17 Aug 2004 21:04:09 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: My own handy Pocket Reference notes
Message-Id: <cftrs9$5hs$1@mamenchi.zrz.TU-Berlin.DE>

Randal L. Schwartz <merlyn@stonehenge.com> wrote in comp.lang.perl.misc:
> >>>>> "Ala" == Ala Qumsieh <notvalid@email.com> writes:
> 
> Ala> David Filmer wrote:
> >> To set a variable to the greater (larger) of two choices:
> >> $var = ($a > $b) ? $a : $b;
> 
> Ala> I find this a bit more amusing, although less maintainable:
> 
> Ala> 	$var = [$b => $a] -> [$b <= $a];
> 
> And more expensive.  All the work to create an anonymous list, then an
> anonymous array from that, take a reference to it, dereference it, and
> then pull one of the two items back out, and then discard the array
> and the list value.
> 
> Ugh.
> 
> Please shoot the person who came up with that cute hack.  That's
> just as cutesey (and dangerous) as rename $x => $y.  Ugh.

Hey, it's a joke.  I don't think anyone is suggesting it in earnest.
Not that a warning isn't in place, once it has appeared on Usenet.

However, the related

    sub min { $_[ $_[ 1] < $_[ 0]] }

doesn't have unnecessary overhead.  It is in fact quite fast, and
I have used it occasionally.

Anno


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

Date: Tue, 17 Aug 2004 20:57:57 +0200
From: "JJ" <geenbestaandadres@lycos.nl>
Subject: Re: Operator for presence of value in list?
Message-Id: <4122554b$0$62353$5fc3050@dreader2.news.tiscali.nl>

I'm even more lazy than Martin, why does nobody copy-paste the faq here?

Vincent

"Gunnar Hjalmarsson" <noreply@gunnar.cc> schreef in bericht
news:2oea84F9p19eU1@uni-berlin.de...
> Bernard El-Hagin wrote:
> > Gunnar Hjalmarsson wrote:
> >> Bernard El-Hagin wrote:
> >>>
> >>>   perldoc -f grep
> >>
> >> Quote from the applicable Perl FAQ ("perldoc -q contained"):
> >>
> >> "Please do not use
> >>
> >>     ($is_there) = grep $_ eq $whatever, @array;
> >>
> >> or worse yet
> >>
> >>     ($is_there) = grep /$whatever/, @array;
> >>
> >> These are slow (checks every element even if the first matches),
> >> inefficient (same reason), and potentially buggy (what if there
> >> are regex characters in $whatever?)."
> >
> > Good, you're paying attention. ;-)
>
> Yeah, I like being a pain in the a**. :)
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl




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

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 V10 Issue 6876
***************************************


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