[11964] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5564 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 4 20:07:31 1999

Date: Tue, 4 May 99 17:00:20 -0700
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, 4 May 1999     Volume: 8 Number: 5564

Today's topics:
    Re: "learning perl" does not seem to be written well (Kvan)
    Re: "learning perl" does not seem to be written well <uri@sysarch.com>
    Re: "learning perl" does not seem to be written well <cassell@mail.cor.epa.gov>
    Re: An attempt to compare the performance of perl vs co <cassell@mail.cor.epa.gov>
        array shuffling tvn007@my-dejanews.com
        Controlling Serial Control Lines? <rtoren@bronzedragon.net>
    Re: E-Mail Attachments <sugalskd@netserve.ous.edu>
    Re: global var disappearing, reappearing <sugalskd@netserve.ous.edu>
    Re: Help: How to deal with a $ in string match <aqumsieh@matrox.com>
    Re: How do I hide my source code (was Re: Making execut <tchrist@mox.perl.com>
    Re: how do I slurp a file into a string <Tim.Potter@anu.edu.au>
    Re: how do I slurp a file into a string <uri@sysarch.com>
    Re: how do I slurp a file into a string <uri@sysarch.com>
        I'm new - Please help - Sorting Question <news@i-tradeonline.com>
    Re: killing or interrupting Threads - how? <sugalskd@netserve.ous.edu>
    Re: Limit to number of if statements??? <design@raincloud-studios.com>
    Re: Limit to number of if statements??? <uri@sysarch.com>
    Re: Limit to number of if statements??? <uri@sysarch.com>
    Re: Limit to number of if statements??? (Andrew Allen)
    Re: Making executables from .pl files? <tchrist@mox.perl.com>
    Re: Perl 5: The Complete Reference, Martin Brown <uri@sysarch.com>
    Re: Perl and Threads <sugalskd@netserve.ous.edu>
    Re: Perl in the workplace <sugalskd@netserve.ous.edu>
    Re: RFC: s/The Perl Institute/Perl Mongers/g; <jbc@shell2.la.best.com>
        sub for re-encoding a url <enigma@turingstudio.com>
    Re: sub for re-encoding a url <design@raincloud-studios.com>
    Re: sub for re-encoding a url <enigma@turingstudio.com>
        url encoding <enigma@turingstudio.com>
    Re: url encoding <design@raincloud-studios.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 04 May 1999 22:07:17 GMT
From: kvan@dis.dk (Kvan)
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <372f6e9a.56770621@news.newsguy.com>

On Wed, 28 Apr 1999 09:48:19 -0700, David Cassell
<cassell@mail.cor.epa.gov> wrote:

>Ah yes.  For fun, try to say "I am full" after eating with a European.
>The literal translation is (in several languages) a euphemism for
>"I am pregnant."  Oops!  
>
>Breaks the ice at any party!

It works a lot better in Scandinavian countries, where the literal
translation means "I'm drunk". :)

Speaking of Perl, though, I've recently switched jobs and find myself
having to use, horror of horrors, VBScript (the atmosphere, tasks and
pay are better, though, so it's worth it). Due to the extremely low
"useful factor" of VBS as compared to Perl, I have actually found
myself writing a bunch of Perl programs to write VBS code for me.
That's how much more I like Perl.

Kvan.

-------Casper Kvan Clausen------ | 'A *person* is smart. People are
---------<kvan@dis.dk>---------- |  dumb, panicky, dangerous animals
                                 |  and you know it.'
                                 |        - "K" in Men in Black.


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

Date: 04 May 1999 19:03:09 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <x7pv4g1lqq.fsf@home.sysarch.com>

>>>>> "DC" == Damian Conway <damian@cs.monash.edu.au> writes:

  DC> Uri Guttman <uri@ibnets.com> writes:
  AJ> One book rather like that should be out sometime in August:
  AJ> http://www.manning.com/Johnson/

  >> i won't judge this book until i see it, but the publisher has left me
  >> cold. they spammed this group and various perl hackers via email about
  >> their books, never sent any followup information, and in general
  >> seemed to be unsavory fellows.

  DC> Up-front disclaimer: I have a book about to be published by Manning.

  DC> The message that was sent to "various perl hackers" was a
  DC> politely-worded invitation to write for the publisher, which is trying
  DC> to establish a presence in the Perl market. When some of those
  DC> "hackers" publicly queried the targeting and format of the message, a
  DC> public apology was posted (to p5p). That indicates an original lack of
  DC> understanding of netiquette on the part of a single Manning employee
  DC> (who is no longer with the company), but it's hardly a pattern of
  DC> unsavory behaviour.

my complaint was more about the later part of the relationship with
manning. they asked for potential reviewer and i said i might help. they
never followed up on that and it annoyed me. i have heard from others
about similar behavior from them. so it may not be unsavory (i am
allowed some perl poetic license) but not professional nor courteous.

  DC> In the case of my own forthcoming book, Manning have gone to a great
  DC> deal of trouble to find competent and reliable reviewers. Being new to
  DC> Perl publishing, they didn't have the same connections as O'Reilly, so
  DC> they were forced to make unsolicited approaches to suitable people.
  DC> They never tried to sell them anything - they just asked if they'd
  DC> be interested in writing or reviewing a new book. Again, that's
  DC> hardly spam.

  DC> Perhaps Uri is aware of other behaviour that was somehow inappropriate,
  DC> but, checking through dejanews, it's not evident to me.

the way they did it irritated many others. i will have to go back and
look at dejanews myself. i don't recall those threads being fun for the
perl community.

  DC> Of course he's right to be wary of new Perl publishers, since the books
  DC> they publish often don't live up the high standard that O'Reilly has
  DC> set. But it's unfair to cast aspersions on the likely quality of the
  DC> books even before they've been published.

as i said, i won't judge the books until i see them. but beware, i am
ruthless! see my post today about "perl: the imcomplete reference"
published by osborne/mcgraw-hill. i should star in farrenheit 451 based
on my review.

  DC> I'm sure Uri isn't prejudging the books himself, but his stature in the
  DC> Perl community means that he may be prejudicing others against them. By
  DC> all means burn Andrew and myself at the stake if our Manning-published
  DC> books eventually suck, but please don't light the fire until then.

i will cut you that slack. a good perl book will stand on its own
merits. unfortunately so few have come outside of o'reilly (effective
perl, perl - progammer's companion, come to mind). and o'reilly has the
experience and ability from creating their vast library of useful
computer books. it'll be very hard to crash that party with a upstart
publisher. look at all the other bad perl books put out by supposedly
reputable publishers. in fact many of their other computer books are
poor too with the same mediocre formatting (as tom c would agree, it is
critical to a good computer book), countless typos and real errors, no
owning of the errors with on-line eratta pages, etc.

so you do have some baggage to carry regardless of what is say. i wish
you luck. maybe send some review copies this way. i asked for that
before and was ignored. now you say i have some stature in this field,
but manning has not treated me with any respect so far.

uri


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Tue, 04 May 1999 16:36:25 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <372F8479.F1091424@mail.cor.epa.gov>

Andrew Johnson wrote:
> 
> In article <7gnb9b$jbb$1@nnrp1.dejanews.com>,
>  birgitt@my-dejanews.com <birgitt@my-dejanews.com> wrote:
>  In article <x3y7lqqnn75.fsf@tigre.matrox.com>,
> 
> !  There are more than enough pretty good "simple" books out there. I was
> !  more thinking in lines of a comprehensive programming textbook,
> !  which doesn't have to be simple and easy, just suitable to be used as
> !  "the" textbook for incoming undergraduates to learn programming. For people
> !  who never have written any program and don't know what an algorithm, loop,
> !  hash, stack, handler, pointer etc is.
> 
> <shameless plug>
> 
> One book rather like that should be out sometime in August:
> http://www.manning.com/Johnson/
> 
> </shameless plug>

[saunters on over to www.manning.com ... looks about... ]

A Masters in anthro?  Neat!  

So you opted to program rather than wave a fan in Dilbert's office,
huh?  :-)

David {who started college as an English major...}
-- 
David Cassell, OAO                            cassell@mail.cor.epa.gov
Senior Computing Specialist                      phone: (541) 754-4468
mathematical statistician                          fax: (541) 754-4716


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

Date: Tue, 04 May 1999 16:13:11 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: An attempt to compare the performance of perl vs compiled perl vs C
Message-Id: <372F7F07.5C51A7C5@mail.cor.epa.gov>

Jonathan Stowe wrote:
> 
> Steven Elliott <elliotsl@NOSPAMmindspring.com> wrote:
> > David Cassell wrote:
> >>
> >> I found your Perl program impossible to access, so I can't evaluate
> >> it.  Perhaps you might want to post it...
> >
> > It is embedded in my post as plain text since my news tool (Netscape)
> > did not use any encoding.  In any case here it is:
> 
> It showed up as an multipart attachment here - Its generally better to
> just stick the code in your post than attach it.

Ditto here.  In fact, I couldn't even read it using Nyetscape as a
newsreader!  I agree with tchrist.  Nyetscape is a news tool only
in the sense that Pravda was a tool of the Russian government.  :-)
No, I can think of another sense in which it's a tool.. but I can't
express that in a family newsgroup...

David
-- 
David Cassell, OAO                            cassell@mail.cor.epa.gov
Senior Computing Specialist                      phone: (541) 754-4468
mathematical statistician                          fax: (541) 754-4716


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

Date: Tue, 04 May 1999 22:37:30 GMT
From: tvn007@my-dejanews.com
Subject: array shuffling
Message-Id: <7gnsra$357$1@nnrp1.dejanews.com>

Hi,

Would some one help me with this problem ? I would really appreciate.

Here is the problem:

I have to set of inputs:

1) first set of input is the header as follow:

  i1  i2  i3  i4  i5  i6  i7  i8  i9  i10

2) second set of input is binary number as follow:

  0   1    1   1   0


The output should be as follow:

the first 0 should be assign to i2
the fisrt 1 should be assign to i5
the second 1 should be asign to i4
the third  1 should be asign to i9
and the second 0 should be asign to i10

I have to asign i1, i3,i6,i7,i8 to "X"


The final output should be like this:

i1  i2  i3  i4  i5  i6  i7  i8  i9  i10

X   0   X   1   1   X   X   X   1    0


Thanks in advance,





-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 04 May 1999 23:24:00 GMT
From: RRrp Toren <rtoren@bronzedragon.net>
Subject: Controlling Serial Control Lines?
Message-Id: <372F81D0.DB705407@bronzedragon.net>

Folks;
  Tomorrow I have to do some interface testing of an RS-232 interface. 
I am on a Linux system, the other end is SCO. The SCO box passes data
based upon hardware flow control.

I see that there is a Windows CommPort module, but is there a
module/method
for manipulating the control lines under Unix (RedHat 5.2 specifically)?


Rip 
rip@bronzedragon.net


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

Date: 4 May 1999 23:12:29 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: E-Mail Attachments
Message-Id: <7gnust$c7l$3@news.NERO.NET>

David Cassell <cassell@mail.cor.epa.gov> wrote:
: John J. Straumann wrote:
:> 
:> Hey All:
:> 
:> I am sending mail via a PERL script that looks like this:
[Snip try one]
:> Can anyone give me an example of how to attach an .exe file?
:> 
:> I tried it like this:
[Snip try two]
:> but no joy...

: You might have better luck if you try doing this using the MIME
: modules available at CPAN.  MIME::Base64 (en|de)codes base64
: strings.  And MIME::Lite should solve your attachment problem.

And just as a plug, Issue 14 of The Perl Journal should have an article in
it on building MIME mail. (And another on sending mail from perl without
needing sendmail)

					Dan


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

Date: 4 May 1999 23:06:55 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: global var disappearing, reappearing
Message-Id: <7gnuif$c7l$2@news.NERO.NET>

Otis Gospodnetic <otis@my-dejanews.com> wrote:
: Hi,

: What is the correct way to declare a global variable that is to be visible
: from all subroutines in the program?

: I thought:
: my $foo = 'bar'; # correct
: $foo = 'bar';    # bad

: The latter causes a warning with 'use strict'. However, I noticed that the
: former may make $foo undefined in some subroutines.

It shouldn't as long as you coordinate access to the variables with lock.

[Snip]
: sub getID
: {
:     return (shift @ids);
: }

Bad, Bad programmer! <thwack> No biscuit for you! You're not locking @ids
before accessing it. (Plus it's global data, which is usually bad
regardless of how you created it. But that's a separate issue) You must,
must, *must* use lock() on anything that two threads may access
simultaneously. 

Any time a perl variable may get modified, you must lock() it first,
before a write *or* a read. (And remember, $a = 1; print $a; modifies $a
*twice*, once on the assignment and once when perl promotes $a from an
integer to a string) Otherwise you're just asking for trouble.

Hopefully 5.005_04 and 5.006 will be a little kinder on readers, but as of
now, it's possible to catch a variable in a half-built state.  Perl ops
are *not* atomic. 

					Dan


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

Date: Tue, 4 May 1999 17:15:07 -0400 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Help: How to deal with a $ in string match
Message-Id: <x3yso9ca65g.fsf@tigre.matrox.com>


Neville Hobson <neville_hobson@mentor.com> writes:

> I'm sure this is simple regular expression stuff but I've just been
> caught by the following situation:
> 
> my $firstname = '$fred';
> my $fullname = '$fred_flintstone';
> my $surname = $fullname;
> $surname =~ s/$firstname//;
> print $surname;
> 
> Whilst the strings have a $ in them the interpolated pattern doesn't get
> a match so $fred_flintstone is what is printed. If you remove the $ it
> works just fine. How should one deal with the $? I have no choice - the
> string to be tested may have a $ as the first character. I guess I
> could strip the $ of first and add it back later.

You should read more about regexps first. I suggest you go ahead and
read 'perlre'. You might also want to read about the quotemeta
function in perlfunc.

Once you read that, you will now that you can do the following:

	$surname =~ s/\Q$firstname//;

HTH,
Ala



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

Date: 4 May 1999 17:15:52 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How do I hide my source code (was Re: Making executables from .pl files?)
Message-Id: <372f7fa8@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    "Asbjorn Gjemmestad" <agjemmes@extremeonline.com> writes:
:It's not that it's embarassing - Just that I don't want people to mess with
:my code 

Then don't give it to them.

And fix the attitude.  I don't know why you won't want others
to improve your code.  But they won't, so it doesn't matter.

--tom
-- 
"I've decided I don't want to be a manager.  Every time you try to be responsive to your employees, they 
say you're being reactive and not proactive.  And when you try to be proactive, they accuse you 
of being capricious and arbitrary.  So I don't wanna be a manager...  " --Larry Wall


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

Date: 05 May 1999 09:09:41 +1000
From: Tim Potter <Tim.Potter@anu.edu.au>
To: tbrannon <brannon@quake.usc.edu>
Subject: Re: how do I slurp a file into a string
Message-Id: <6yg15czb2i.fsf@acronym.anu.edu.au>

tbrannon <brannon@quake.usc.edu> writes:

> ## HERE: I want to slurp the file into $file_contents in one line of Perl.

my @file_contents = <F>;

-- 
Tim Potter, System Admin/Programmer, Head Bee Guy
Advanced Computational Systems CRC, RSISE Bldg Australian National University,
Canberra 0200, AUSTRALIA Ph: +61 2 62798813 Fax: +61 2 62798602


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

Date: 04 May 1999 19:24:04 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: how do I slurp a file into a string
Message-Id: <x7aevk1krv.fsf@home.sysarch.com>

>>>>> "t" == tbrannon  <brannon@quake.usc.edu> writes:

  t> #!/usr/bin/perl

  t> system "rm -f joblist.asp";
  t> system "wget http://registry.yosemite.cc.ca.us/JobBank/joblist.asp";

do you want a shell script or a perl program. both of these can be done
just as easily and faster in perl.

  t> open J, "joblist.asp";

did this actually open the file? ALWAYS check the result of open (and
other system calls)

  t> ## HERE: I want to slurp the file into $file_contents in one line of Perl.

  t> $file_contents='';
  t> while (<F>) {
  t>   $file_contents = $file_contents . $_;
  t> }

that works. but it is slow and highly inefficient.

first off, learn about assignment operators like .=

then learn about list context for <F>

then learn about the special variable $/ and setting it to undef.

when you have mastered all that, then you can incant the magic perl
code:

	$contents = do{ local( @ARGV, $/ ) = 'joblist.asp' ; <> } ;

yechhhh! i loaded an asp file!!!

BTW don't incant that magic code (from abigail) unless you understand
each and every part of it.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 04 May 1999 19:36:33 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: how do I slurp a file into a string
Message-Id: <x73e1c1k72.fsf@home.sysarch.com>

>>>>> "TP" == Tim Potter <Tim.Potter@anu.edu.au> writes:

  TP> tbrannon <brannon@quake.usc.edu> writes:
  >> ## HERE: I want to slurp the file into $file_contents in one line of Perl.

  TP> my @file_contents = <F>;

nice try, but that is not $file_contents which he asked for, but
@file_contents.

besides reading the other posts you could then do a

$file_contents = join( '', @file_contents ) ;

to solve the actual request.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Tue, 04 May 1999 16:39:32 -0700
From: Chance Houston <news@i-tradeonline.com>
Subject: I'm new - Please help - Sorting Question
Message-Id: <372F852C.36483770@i-tradeonline.com>

I'm building a www directory site.  I have all the cgi's in place except for one.

I've written a simple search engine but I want the results to be sorted by the number of clicks a site has recieved.

My database is a text file that looks like this . . .

major_category|sub_category|site_url|site_title|description|feature|graphic|keywords|clickCount

What is the best way to sort my search results by the last item (clickCount)?

A simple answer is all that I'm looking for.

Thanks

Chance Houston



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

Date: 4 May 1999 23:30:44 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: killing or interrupting Threads - how?
Message-Id: <7gnvv4$c7l$6@news.NERO.NET>

Otis Gospodnetic <otis@my-dejanews.com> wrote:
: Hello,

: is killing/interrupting Threads possible in Perl today?

: my scenario: main thread starts X threads (work crew) and each of them
: invokes something via system() something that can take a long time and may
: have to be interrupted and stopped cleanly. I can catch signals in the main
: thread/program (tid 0), but can't figure out how to catch them in other
: threads nor how to stop or kill a thread, etc. Is that currently possible or
: would I be better off forking X processes and killing their PIDs instead?

: I read Thread man page as well as perlthrtut, but handing of signals is not
: covered there :(

Nope, no can do. Perl 5.006 may have support for stopping threads, but
it'll be a long time (if ever) before stopping a thread that's blocking on
a system call is either safe or clean. (or, on some systems, even
possible)

						Dan


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

Date: Tue, 04 May 1999 23:06:03 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Limit to number of if statements???
Message-Id: <v3LX2.944$iu1.1368@news.rdc1.tn.home.com>

>Much neater:
>
>    &{$town_to_builder{$FORM{Key4}} || \&unreferred}};


Hmmm... I've been using something like this to grab which image button
was clicked for form submissions. I have a question...

sub button_action{

  my %actions=(
  'tsu_st_show_index.x'                => sub{ &st_show_index; },
  'tsu_st_show_log_index.x'            => sub{ &st_show_log_index; },
  'tsu_st_execute_log_delete.x'        =>
sub{ &st_execute_log_delete; },
  'tsu_st_execute_log_backup.x'        =>
sub{ &st_execute_log_backup; });

  my $button='';
  foreach $button($query->param){
    if (defined $actions{$button}){
      &{$actions{$button}};
      return;
    }
  }
  &st_show_index;
  exit;
}

Yeah... I know. I can obviously kill the sub{}(s) in favor of \&
Calling a sub from a sub in a hash from a loop. That's gotta be a
performance killer. :)

I used to have the actual subs in there but it was impossible to read
coherently, so I split it up. Wasn't aware I could just call the sub in
the hash like that.

2) Is there any way I can kill my loop in favor of one statement like
you have mentioned here? That would be really slick. When I have like 20
buttons I know I'm taking a performance hit in that loop while it's
checking to see where to go. The sub serves as a 'gateway' of sorts to
many smaller script functions and I'd like to get it as quick as
possible.

You are using one pre-named form element and evaluating it's value to
call the matching sub from the hash element. Can it be modified to work
off the name of the param itself so that virtually any named button
could be evaluated? I've tried a couple of things but so far it's eluded
me.

CT




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

Date: 04 May 1999 19:11:54 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Limit to number of if statements???
Message-Id: <x7g15c1lc5.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> [Posted and a courtesy copy mailed.]
  LR> In article <39emkwblgs.fsf@ibnets.com> on 04 May 1999 16:58:59 -0400, 
  LR> Uri Guttman <uri@ibnets.com> says...
  LR> ...
  >> my %town_to_builder = (
  >> 
  >> #Homeworks Modular Homes -
  >> Bronx	=>	\&builder_32,
  >> 
  >> Albany	=> 	\&builder_05,
  >> ) ;
  >> 
  >> &{$town_to_builder{ $FORM{'Key4'} }} ;
  >> 
  >> tadah! nice and neat!

  LR> Too neat, unfortunately.  What happens if the hash lookup fails?

  LR>   	&{defined $town_to_builder{$FORM{Key4}} ?
  LR>              $town_to_builder{$FORM{Key4}} : \&unreferred}};



larry,

you know me better than that. my preface said 'like' so i was just
showing a basic dispatch table. yes, i would have checked for a bad
value. i am guilty (like randal convicted someone recently for not
testing the return of a regex before using $1).

what is my punishment? to read more of "perl: the incomplete reference"?

that is too painful to imagine.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 04 May 1999 19:33:55 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Limit to number of if statements???
Message-Id: <x767681kbg.fsf@home.sysarch.com>

>>>>> "CRT" == Charles R Thompson <design@raincloud-studios.com> writes:

  CRT> Yeah... I know. I can obviously kill the sub{}(s) in favor of \&
  CRT> Calling a sub from a sub in a hash from a loop. That's gotta be a
  CRT> performance killer. :)

yes.

  CRT> I used to have the actual subs in there but it was impossible to read
  CRT> coherently, so I split it up. Wasn't aware I could just call the sub in
  CRT> the hash like that.

what is the difference between sub{} and \&foo?

  CRT> 2) Is there any way I can kill my loop in favor of one statement like
  CRT> you have mentioned here? That would be really slick. When I have like 20
  CRT> buttons I know I'm taking a performance hit in that loop while it's
  CRT> checking to see where to go. The sub serves as a 'gateway' of sorts to
  CRT> many smaller script functions and I'd like to get it as quick as
  CRT> possible.

  CRT> You are using one pre-named form element and evaluating it's value to
  CRT> call the matching sub from the hash element. Can it be modified to work
  CRT> off the name of the param itself so that virtually any named button
  CRT> could be evaluated? I've tried a couple of things but so far it's eluded
  CRT> me.

very easy. just don't check for each possible param. since you didn't
post any of the form code (please don't!) i can't code it exactly but
you make all the buttons have the same name but a unique value. then you
just get that value from param('button_name') and dispatch based on
that. 

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 4 May 1999 23:41:45 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: Limit to number of if statements???
Message-Id: <7go0jp$r41$1@fcnews.fc.hp.com>

Larry Rosler (lr@hpl.hp.com) wrote:
: [Posted and a courtesy copy mailed.]

: In article <39emkwblgs.fsf@ibnets.com> on 04 May 1999 16:58:59 -0400, 
: Uri Guttman <uri@ibnets.com> says...
: ...
: > my %town_to_builder = (
: > 
: > #Homeworks Modular Homes -
: > 	Bronx	=>	\&builder_32,
: > 
: > 	Albany	=> 	\&builder_05,
: > ) ;
: > 
: > 	&{$town_to_builder{ $FORM{'Key4'} }} ;
: > 
: > tadah! nice and neat!

: Too neat, unfortunately.  What happens if the hash lookup fails?

:   	&{defined $town_to_builder{$FORM{Key4}} ?
:              $town_to_builder{$FORM{Key4}} : \&unreferred}};

Bah! What's wrong with '$town_to_builder{""}=\&unreferred'? Fear of
undefs is a regurgitory response to too much kid-gloving by the
nandy-pandy -w! ;)

Andrew


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

Date: 4 May 1999 17:14:59 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Making executables from .pl files?
Message-Id: <372f7f73@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    "Asbjorn Gjemmestad" <agjemmes@extremeonline.com> writes:
:I am looking for a way to make executables 

chmod +x

:from my .pl files 

What would you execute a library?

:to avoid
:shipping my source code with my programs. 

Don't ship the programs.  

:I know perl2exe does just that,

It does?  Look closely.

:but they charge $500 for a full package, so I thought I'd check in here
:first.

:I need to compile files 

No, you don't.

:for at least unix systems (as many variations as
:possible), but hopefully also windows and solaris. Can anyone help me?

Probably, but ability and volition may have different values here.

--tom
-- 
    I think I'm likely to be certified before Perl is...  :-)
        --Larry Wall in <1995Feb12.061604.6008@netlabs.com>


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

Date: 04 May 1999 19:08:55 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl 5: The Complete Reference, Martin Brown
Message-Id: <x7k8uo1lh4.fsf@home.sysarch.com>

>>>>> "JA" == Jack Applin <neutron@fc.hp.com> writes:

  JA> Uri Guttman (uri@ibnets.com) wrote:
  >> the final insult is this one:
  >> 
  >> <STUPID BOOK>
  >> Don?t use eval when you can use braces to expand information inline
  >> such as variable names. You can use something like :
  >> 
  >> ${$prefix . $var} = "String";
  >> </STUPID BOOK>
  >> 
  >> he advocates symbolic refs over eval!! but no mention here of data
  >> structures. 

  JA> I agree with the book here--symbolic refs are better than eval in
  JA> this case.  Using eval opens up a BIG door--anything could be in
  JA> that string to be evaluated.  Symbolic refs, on the other hand,
  JA> perform a symbol table lookup and that's it.  It's simpler.

  JA> There may certainly be times when you need eval, but you should use
  JA> a less powerful construct when you can.  It's like goto: there are
  JA> times when using goto in C may be best, but use limited constructs
  JA> such as break and continue when you can.

i am sorry, but you missed the boat. symbolic references are bad unto
themselves, not just as a different method from eval. use data
structures. this has been asked umpteen times recently in this
group. have you read any of those posts (and tom's replies)? do you read
the FAQ yourself?

eval good (when needed)! symbolic refs bad! data structures better!

so the book is wrong as i stated.

BTW one of our esteemed regulars (larry rosler) is an hp guy. you might
want to look him up and learn some perl.

any anger detected in this post is left over from my review. i was really
pissed at the arrogance of the blurb on the main page and then to find
so many blatant and bad errors. 

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 4 May 1999 23:27:46 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: Perl and Threads
Message-Id: <7gnvpi$c7l$5@news.NERO.NET>

Thomas van Gulick <melkor@utumno.student.utwente.nl> wrote:
: I'm a bit confused, but do I have to compile a 'threaded Perl' to be able to
: use the Thread package of Perl, or does 'thread Pearl' just mean Perl uses
: thread internally?

: I ask this because I fail to compile Apache with mod_perl when Perl is
: 'threaded'. It segfault on loading mod_perl. I'd like to use a non 'threaded
: Perl' but I'm not sure whether I can 'use Thread's :)

Threads are experimental--if you want to use them you *must* build perl
with support specifically for them.

You don't want to build mod_perl with threads, though. Really. Threaded
perl is *Not* in any way, shape, or form production ready. Build it
separately to play with if you like, but don't make it your production
perl. (It's not worth the performance hit when running without threads,
though it's stable in that case)

					Dan


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

Date: 4 May 1999 23:23:58 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: Perl in the workplace
Message-Id: <7gnvie$c7l$4@news.NERO.NET>

sstarre@my-dejanews.com wrote:

: I work for a large Fortune company, where use of Perl is a forbidden
: practice. There are two distinct camps - MIS, who mandates that all CGI will
: be done in VB-script (ack!), and two, engineers and scientists who use an
: ecclectic mix of languages. In my camp (the latter) a small band of us risk
: our employment daily and continue to write our CGI in Perl. Proabably less
: than 20 people in this company of over 20,000 use Perl. We download it and
: install it on our Suns, so largely we're safe from MIS probing which only
: (today) extends into the NT and VMS domains.

If it'll help, point out that perl runs quite nicely on VMS. (And I'd bet
they'd get better performance and definitely more reliability if their
webserver was on the VMS box, but that's a separate rant) I've got quite a
few perl programs running on my cluster. Heck, tell 'em to sign up for the
VMS perl intro seminar at DECUS/Providence in June. (Which, in the
interest of full disclosure, I'm giving)

VB-script. Sheesh.

					Dan


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

Date: 04 May 1999 23:31:53 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: RFC: s/The Perl Institute/Perl Mongers/g;
Message-Id: <372f8369$0$224@nntp1.ba.best.com>

brian d foy <brian@pm.org> wrote:

> Perl Mongers is following an old rule of the sea that when one
> takes over the watch on the ship, the sail is not changed for one
> bell.

This is completely off-topic, but in a lifetime of sailing I've never
heard of such a rule, and can't believe one has ever existed. At sea (if
not at the helm of volunteer Perl organizations), conditions can change
dramatically in just a few minutes. Keeping an inappropriate suit of
sails up until the next bell sounds (as long as 30 minutes) because of
some arbitrary rule would be crazy.

The first rule a sailor learns is that when conditions change, you have
to adapt - instantly.

We now return to our regularly scheduled relevance flames...

-- 
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: Tue, 04 May 1999 16:17:05 -0700
From: "Alex Black" <enigma@turingstudio.com>
Subject: sub for re-encoding a url
Message-Id: <372f7ee4$0$223@nntp1.ba.best.com>

hi,

I've got a url that's been decoded, i.e. from:

file%3A%2F%2F%2Fconnaught%2Fsite%2Fimages%2Fshared%2F
to
file:///connaught/site/images/shared

yes, that's hardcoded and referenced to the local machine... no I don't care
yet.

I've got the sub that decodes it (heh), but not the sub that will encode it
for printing... I'm feeding the cgi input through links, as opposed to
submitting a form with get... i.e.
<a href="index.cgi?page=1&dir=$enc_dir">link contents</a>

as you can see, that requires an encoded url.. $enc_dir

anyway, if anyone knows of a site with a bunch of good, free subroutines
(including one that will encode urls) I'd appreciate the address.

best,

_a



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

Date: Tue, 04 May 1999 23:25:26 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: sub for re-encoding a url
Message-Id: <GlLX2.958$iu1.1420@news.rdc1.tn.home.com>

>anyway, if anyone knows of a site with a bunch of good, free
subroutines
>(including one that will encode urls) I'd appreciate the address.


Isn't there a module that handles this?

CGI::Enurl ? I think that's what I saw last week.

http://www.perl.com/CPAN-local/modules/00modlist.long.html#15)WorldWideW
eb

for some reason that link didn't hold up right. You'll probably have to
type or cut and past it.

CT




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

Date: Tue, 04 May 1999 16:43:40 -0700
From: "Alex Black" <enigma@turingstudio.com>
Subject: Re: sub for re-encoding a url
Message-Id: <372f851f$0$207@nntp1.ba.best.com>

I can't find a lib that will encode urls... which kind of surprise me. I 
went looking and I couldn't find much. The following is something I found,
but it's damaged. I have a feeling the ~s lines would do it, but I can't
quite arrange them correctly to fix it.

sub url_encode {
    $dirline = $data{'dir'};
    $dirline = ~s/\?/%3f/g;
    $dirline = ~s/\&/%26/g;
    $dirline = ~s/\+/%2b/g;
    $dirline = ~s/([\000-\037\177-\377 ])/"%".sprintf("%2.2x",ord($1))/ge;
    }
    return $dirline;
}

> CT

thanks CT,

_a





----------
In article <372f7ee4$0$223@nntp1.ba.best.com>, "Alex Black"
<enigma@turingstudio.com> wrote:


> hi,
>
> I've got a url that's been decoded, i.e. from:
>
> file%3A%2F%2F%2Fconnaught%2Fsite%2Fimages%2Fshared%2F
> to
> file:///connaught/site/images/shared
>
> yes, that's hardcoded and referenced to the local machine... no I don't care
> yet.
>
> I've got the sub that decodes it (heh), but not the sub that will encode it
> for printing... I'm feeding the cgi input through links, as opposed to
> submitting a form with get... i.e.
> <a href="index.cgi?page=1&dir=$enc_dir">link contents</a>
>
> as you can see, that requires an encoded url.. $enc_dir
>
> anyway, if anyone knows of a site with a bunch of good, free subroutines
> (including one that will encode urls) I'd appreciate the address.
>
> best,
>
> _a
> 


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

Date: Tue, 04 May 1999 16:18:17 -0700
From: "Alex Black" <enigma@turingstudio.com>
Subject: url encoding
Message-Id: <372f7f2a$0$223@nntp1.ba.best.com>

hi,

I've got a url that's been decoded, i.e. from:

file%3A%2F%2F%2Fconnaught%2Fsite%2Fimages%2Fshared%2F
to
file:///connaught/site/images/shared

yes, that's hardcoded and referenced to the local machine... no I don't care
yet.

I've got the sub that decodes it (heh), but not the sub that will encode it
for printing... I'm feeding the cgi input through links, as opposed to
submitting a form with get... i.e.
<a href="index.cgi?page=1&dir=$enc_dir">link contents</a>

as you can see, that requires an encoded url.. $enc_dir

anyway, if anyone knows of a site with a bunch of good, free subroutines
(including one that will encode urls) I'd appreciate the address.

best,

_a

p.s. if this is a dupe, please pardon. the server bounced me :)


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

Date: Tue, 04 May 1999 23:26:08 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: url encoding
Message-Id: <kmLX2.969$iu1.1300@news.rdc1.tn.home.com>

>p.s. if this is a dupe, please pardon. the server bounced me :)

Answered in previous post.




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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 5564
**************************************

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