[13486] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 896 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 24 02:07:20 1999

Date: Thu, 23 Sep 1999 23:05:13 -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: <938153113-v9-i896@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 23 Sep 1999     Volume: 9 Number: 896

Today's topics:
    Re: ?? Search Engine Addresses for Submission ?? (Larry Rosler)
    Re: beauty of a Y2K bug (Kragen Sitaker)
        Calling Mac 'ToolBox' Function via MacPerl (Samuel)
    Re: can i get a witness? (Greg Andrews)
    Re: can i get a witness? (Greg Andrews)
    Re: Case insensitive SQL query (Mark W. Schumann)
    Re: decomposing an outline-style text body (ugly regexp <kbandes@home.com>
        Hats off to Chris Durbin ! KernelKlink@webtv.net
    Re: How to split one variable into two? (Tal Yarkoni)
    Re: HTML to ASCII <help@casinofantasy.com>
    Re: Pass by reference (Larry Rosler)
    Re: Pass by reference (Tramm Hudson)
    Re: Pass by reference (Martien Verbruggen)
    Re: Pass by reference (Martien Verbruggen)
    Re: Pass by reference (Larry Rosler)
        Perl and Ms Personnal Web server <abdelkrim@home.com>
        Reference of a Slice bayinnaung@my-deja.com
    Re: Reference of a Slice (Kragen Sitaker)
    Re: Regex & URL parsing... (Kragen Sitaker)
    Re: REQ: tell-a-friend script <tchrist@mox.perl.com>
    Re: Some e-mails get sent, some don't (Mark W. Schumann)
        Spell Checker In Perl <mace@calweb.com>
    Re: Spell Checker In Perl (Martien Verbruggen)
    Re: Using the Expect.pm module w/Perl5.00502 <dboyce@mediaone.net>
    Re: Validating unsafe code? (Kragen Sitaker)
    Re: You should be admired, or What does this have to do <elaine@chaos.wustl.edu>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 23 Sep 1999 20:45:54 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: ?? Search Engine Addresses for Submission ??
Message-Id: <MPG.125493cb250a5257989fd2@nntp.hpl.hp.com>

In article <7seotu$7ub$1@nnrp1.deja.com> on Fri, 24 Sep 1999 02:50:41 
GMT, petrovitch@my-deja.com <petrovitch@my-deja.com> says...
> I've written a script to submit and unlimited number of URLs to an
> unlimited number of search engines, but I've only been able to find
> about a dozen search engine addresses, i.e.,
> 
> "http://add-url.altavista.digital.com/cgi-bin/newurl?ad=1&q="
> + "&contact=" + contact + "&email=" + email;

I don't know what programming language that is written in, but it isn't 
Perl ('+' for string concatenation, and barewords for variables).

> Can anyone tell me where to find submissions strings for many of the
> other search engines?

That question has nothing to do with Perl either.

I think you are asking in the wrong place.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 24 Sep 1999 05:53:07 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: beauty of a Y2K bug
Message-Id: <7lEG3.7680$QJ.493122@typ11.nn.bcandid.com>

In article <37EA70AB.4F27427B@mail.cor.epa.gov>,
David Cassell  <cassell@mail.cor.epa.gov> wrote:
>Kragen Sitaker wrote:
>[snip of plaint]
>> I mean, yeah, if you have a hundred-foot-high catwalk without any
>> handrails, you can walk across it every day for years without falling
>> off, if you're careful.  Anyone who falls off probably could have
>> avoided falling, had they been more careful.  But that doesn't mean
>> you're not responsible for putting up handrails.
>> 
>> C has a lot of missing handrails.
>
>No no no, that's not it.
>
>C is a language in which the creators have carefully *removed*
>all the handrails, so experts can bungee-jump whenever they
>want to.  Anyone who goes *splat* shouldn't have tried it.  :-)
>
>David, who has gone *splat* more than once 

Missing handrails like no type safety and no bounds-checking and no
garbage collection I can understand.  It makes your program faster and
compilers simpler, and sometimes makes your program simpler, too.

But what does tm_year being (year -1900) buy you?  You can fit it into
a byte instead of two bytes?  It certainly doesn't make your program
any faster or simpler, and it doesn't make the library any faster or
simpler either.  All it does is cause bugs.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 24 Sep 1999 00:35:16 -0400
From: sleidy_keinSpam_@_bitte_voicencet.com (Samuel)
Subject: Calling Mac 'ToolBox' Function via MacPerl
Message-Id: <1dylzh1.17l0fy845bswN@dialup0722-pri.voicenet.com>

Computer:   Mac IIci
MacOS:      7.6.1
Perl:       MacPerl 5.2.0r4

I wrote a Perl File to go to a designated Folder and modify the Names of
the Files in it.

Everything runs as it should.

I then deceided to change the Files Creator Type also.

All I want to do is add '&Change_File_Type($temp_Directory_Path);'
[where '$temp_Directory_Path' is the Full Path Name] in a SubRoutine I
already have, and add:

sub Change_File_Type {                               # Change File Type
Sub-Routine.
    my($file) = @_;
# Retrieves a Copy of Calling Functions Parameter(s).
    
    my($file_Cat, $file_Info);

    $file_Cat = FSpGetCatInfo $file;
    $file_Info = $file_Cat->ioFlFndrInfo();

    $file_Info->fdCreator('GKON');
    $file_Cat->ioFlFndrInfo($file_Info);
    FSpSetCatInfo $file, $file_Cat;
}

 ... at the bottom of my working Perl File.

If I add 'use Mac::Files' as per the 'MacPerl Power and Ease'
Publication I receive this Error Message:

--- Error Message starts here -----

# Can't find loadable object for module Mac::Files in @INC
(HDD_03:Programming_[Compilers]:MacPerl:lib:Mac HDD_03:MacPerl:lib
Dev:Pseudo)
File 'Dev:Pseudo'; Line 22
# BEGIN failed--compilation aborted.
File 'HDD_02:*Programming
Files:Perl:Sams:Dilbert_Cleaner:Dilbert_Cleaner_02.pl'; Line 22

--- Error Message ends here ----- 

I can see the 'Files.pm' and 'Files.xs' Files in the 'lib:Mac' Folder.

I have installed 'MacPerl' from the 'MacPerl Power and Ease' and 'Perl 5
for Dummies' CD-ROMs and receive the same Errors.

I can use the built-in Macintosh Functions with no Problem - all I need
to know is what do I put where for Macintosh Functions located in
'lib:xxx' [where xxx = 'abbrev.pl' through 'WWW'] Files?

Will someone show me what am I doing wrong or missing?

Thanks,

Samuel


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

Date: 23 Sep 1999 22:44:32 -0700
From: gerg@shell.ncal.verio.com (Greg Andrews)
Subject: Re: can i get a witness?
Message-Id: <7sf340$f3b$1@shell1.ncal.verio.com>

Jonathan Cooper Weiss <jcweiss@cats.ucsc.edu> writes:
>
>anyway, i have since left the project (due to previous time commitments)
>only to be informed by my past employers that their potential new guy
>seems to think that PERL is a bad choice for such systems. memory issues
>notwithstanding (i figured it was worth a little RAM for the performance
>benifits of the preloaded code and DB connections), i find it hard to
>believe that a C solution (which is the only "superior" alternative i can
>imagine he was talking about) would be incomparably better. not having a
>really deep understanding of the internals (and having been semi out of
>the biz for 8 months), i was wondering if i could get some more input on
>this -- at least for my own sense of where things stand. 
>

Do you really need to defend your solution?

As I see it the facts of the matter are:

  o  You implemented the solution in an amount of time that
     was, I assume, satisfactory to your then-employer.

  o  The features and performance of your solution are also
     satisfactory to your then-employer.


If your employers are willing to pay (again) the costs of
developing a solution, then that's their perogative.

You haven't said so, but I would guess that your former employer is
trying to decide whether they want to throw the funds they spent on
the current solution down the drain and spend more funds on a completely
different solution.


The questions I would encourage them to ask are:

  o How much of a gain in features, performance, or scalability will
    the new solution give over the existing solution?  (I.e. if the
    end result is only a 10% performance boost, the return on investment
    will probably be too low)

  o How many times has the new guy implemented the solution he proposes?
    If he's done similar solutions, how similar?  How recently?
    (I.e. is he talking through his hat, or does he have real experience
    wrestling with the problems to be solved? [and the design compromises
    imposed by the real world on any project])


If they still decide to have him build a new solution from scratch, I
would encourage them to keep their existing, working, already-paid-for
solution in production while he build the new one.  Only after the new
solution has been built, tested, and has proved its superiority will it
be put into production.


The points I would emphasize to them would be that they already have
a bird in hand - a working system.  Dumping it and paying to re-invent
the solution doubles the cost of the new solution.  If the solution
won't double the performance of the current solution, the return on
investment will be bad.  Or if they can't find sufficient reason to
trust the new developer's assurances that it will double the current
performance, then they may want to stick with what they have.

As a side note, solutions with high scalability will tend to fail the
return-on-investment test I outline above.  They make up for it in the
long run.  However, that's where the new guy's experience with the very
same kind of project comes in.  If he's speaking from experience in
building the same solution, that's good.  If he's speaking in theoretical
terms, that's not so good.


The above are just my opinions.  Hope this helps,

  -Greg

-- 
:::::::::::::::::::  Greg Andrews  gerg@wco.com  :::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


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

Date: 23 Sep 1999 22:55:27 -0700
From: gerg@shell.ncal.verio.com (Greg Andrews)
Subject: Re: can i get a witness?
Message-Id: <7sf3of$fbm$1@shell1.ncal.verio.com>

Jonathan Cooper Weiss <jcweiss@cats.ucsc.edu> writes:
>
>anyway, i have since left the project (due to previous time commitments)
>only to be informed by my past employers that their potential new guy
>seems to think that PERL is a bad choice for such systems. memory issues
>notwithstanding (i figured it was worth a little RAM for the performance
>benifits of the preloaded code and DB connections), i find it hard to
>believe that a C solution (which is the only "superior" alternative i can
>imagine he was talking about) would be incomparably better. not having a
>really deep understanding of the internals (and having been semi out of
>the biz for 8 months), i was wondering if i could get some more input on
>this -- at least for my own sense of where things stand. 
>

Do you really need to defend your solution?

As I see it the facts of the matter are:

  o  You implemented the solution in an amount of time that
     was, I assume, satisfactory to your then-employer.

  o  The features and performance of your solution are also
     satisfactory to your then-employer.


If your employers are willing to pay (again) the costs of
developing a solution, then that's their perogative.

You haven't said so, but I would guess that your former employer is
trying to decide whether they want to throw the funds they spent on
the current solution down the drain and spend more funds on a completely
different solution.


The questions I would encourage them to ask are:

  o How much of a gain in features, performance, or scalability will
    the new solution give over the existing solution?  (I.e. if the
    end result is only a 10% performance boost, the return on investment
    will probably be too low)

  o How many times has the new guy implemented the solution he proposes?
    If he's done similar solutions, how similar?  How recently?
    (I.e. is he talking through his hat, or does he have real experience
    wrestling with the problems to be solved? [and the design compromises
    imposed by the real world on any project])


If they still decide to have him build a new solution from scratch, I
would encourage them to keep their existing, working, already-paid-for
solution in production while he build the new one.  Only after the new
solution has been built, tested, and has proved its superiority will it
be put into production.


The points I would emphasize to them would be that they already have
a bird in hand - a working system.  Dumping it and paying to re-invent
the solution doubles the cost of the new solution.  If the solution
won't double the performance of the current solution, the return on
investment will be bad.  Or if they can't find sufficient reason to
trust the new developer's assurances that it will double the current
performance, then they may want to stick with what they have.

As a side note, solutions with high scalability will tend to fail the
return-on-investment test I outline above.  They make up for it in the
long run.  However, that's where the new guy's experience with the very
same kind of project comes in.  If he's speaking from experience in
building the same solution, that's good.  If he's speaking in theoretical
terms, that's not so good.


So I don't percieve a need to defend your solution.  The fact that
it works to their satisfaction is defense enough.

If they're asking you for advice, I would just focus their attention
on the main factor that should influence their decision:  Are they
confident that scrapping the working solution and building a new one
will produce a good return on their investment?  If they decide to do
it, do it in such a way that won't leave them twisting in the wind if
something goes wrong with the development of the new design.


The above are just my opinions.  Hope this helps,

  -Greg
-- 
:::::::::::::::::::  Greg Andrews  gerg@wco.com  :::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


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

Date: 24 Sep 1999 01:09:16 -0400
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: Case insensitive SQL query
Message-Id: <7sf11s$kuf@junior.apk.net>

In article <7sau5d$ekl$1@nnrp1.deja.com>,  <c_j_marshall@hotmail.com> wrote:
>> Instead of flaming the newcomers who demand answers to unPerl
>questions,
>> why don't we do just like this?  I'll answer your MySQL question, but
>> only after you answer my macroeconomics question.
>>
>> *sigh*
>>
>> Maybe _that_ will help get the point across.
>
>Perhaps a more challenging method would be to take every inane off-topic
>question and drag it kicking and screaming into a perl solution.
>
>I was going to reply to this one by telling him to first pull the entire
>table into a hash keyed on the unique field and then loop through using
>m/joe/i to select his records.

Cool.  Thanks.



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

Date: Fri, 24 Sep 1999 03:51:38 GMT
From: Kenneth Bandes <kbandes@home.com>
Subject: Re: decomposing an outline-style text body (ugly regexp question)
Message-Id: <37EAF555.D93490BD@home.com>

Larry Rosler wrote:
> In article <7sdrht$ahh$1@winter.news.rcn.net> on Thu, 23 Sep 1999
> 14:29:11 -0400, George Willman <george.willman@2asc.com> says...
> ...
> > ...  The potential saving grace is a
> > repeating identifying string ("Event:") in each main heading.
> 
> If I understand your problem correctly, the solution is much easier than
> you will believe.
> 
> Look in perlvar for $/ (aka $INPUT_RECORD_SEPERATOR).  You can use it to
> read an entire paragraph into a string with each <FILE> operation.  You
> may have to adjust conditions for the first and last records, but that
> is a small matter of programming.

I'm not quite sure this does it.  Recall that $/ is a string, NOT a 
regexp.  Yes, you could set it to "Event: " and that would work in
most cases (the event #, which precedes the word Event, would be
attached to the wrong event but okay, you can deal with that.), as
long as that string doesn't occur within any of the text.  It seems
to me, though, that the real break is on /^\d+\.\s+Event:/.  But
that's not a valid $/.

Besides, you still have to pick apart each event entry, so why
not do it all in one regexp as George intended in the first place?

Ken Bandes


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

Date: Fri, 24 Sep 1999 00:59:18 -0400 (EDT)
From: KernelKlink@webtv.net
Subject: Hats off to Chris Durbin !
Message-Id: <22086-37EB0526-24@newsd-211.iap.bryant.webtv.net>

I've been thinking it, but Chris had the gut's to say it. Thanks Chris. 

Chris wrote:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0What I am losing respect
for is this newsgroup. I came here to learn and explore the language, to
be a better programmer, and write better code. What I now find myself
faced with is monstrous amounts of bickering and partisan in-fighting.
Finding threads of incredible length that seem to be about nothing more
than a few various responses to childish insults. 
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0I have read some of
Abigail's responses to posts, and I have found them to be insultlingly
condescending as a general rule. Absolutely correct, but very
condescending. She is not alone in this. An atmosphere of exclusivity
seems be bred in here, which is amazing, considering the number of posts
and posters in this group. 
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0Instead of trying to
prove how smart you are by tearing down someone else, why don't you just
simply print an answer. If you know the answer to someone's question,
just answer it. It doesn't have to be an opportunity to score points by
making them seem foolish, even if you think the solution is ridiculously
simple. If someone has posted that question, it obviously stumped them
to the point where they would turn to you jackals for advice. You are
not children, stop acting like them. If you need take pot-shots at each
other go ahead, but stop masking as an authority on anything but
stupidity. Take it somewhere else like comp.lang.perl.useless.chatter or
comp.lang.perl.pointless.insults 
-- 
Chris Durbin =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Motorola, Cellular
Infrastructure Group 
----------------------------------------------



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

Date: 24 Sep 1999 03:03:53 GMT
From: tyarkoni@chat.carleton.ca (Tal Yarkoni)
Subject: Re: How to split one variable into two?
Message-Id: <7sepmp$bck$1@bertrand.ccs.carleton.ca>

Clayton L. Scott (tex@engsoc.carleton.ca) wrote:
> You, yes you, Tal. Stop writing stuff like this:
> : This is a pretty straightforward question (I think)... I'm a beginner and
> : need to know how I can create two strings from one.. I don't mean
> : splitting the content of the variable; I mean creating two variables of
> : the same name plus something like 1 or 2 appended to the end... so for example
> : if i have a foreach loop going I'm aware I can define a new variable with

> 	What task are you trying to perform? I can see no reason to do
>  this the way you describe it. If you describe your real problem maybe
>  someone can help you come up with a better solution.

Hmm... I thought it'd be just a question of syntax... the task involved is
the scoring of an online test. I need to take a radio-button name and turn
it into two strings based on that name. I can end up with two strings by
making the name of each question longer (i.e. make the value AB instead of
A, and then just split A and B separately rather than have A1 and A2.)
Actually I did it this way for another test. But for obscure reasons
(having to do with the fact that there are nearly 50 different groups being
tested for here and I'd prefer not to have button names like "32-45") I
would much rather do it by taking a single value and creating two strings
with similar names. Actually there are a couple of other reasons for it
that have to do with just what the test is testing for, the things it's
testing for, and the fact I don't want people to be able to look at the
page source and be able to easily figure out the scoring schema.

If there's no simple way to do it I guess I'll do it the same way... I
just thought it'd be a relatively easy fix. I'd appreciate any ideas...


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

Date: Fri, 24 Sep 1999 14:20:40 +1000
From: Anonymous <help@casinofantasy.com>
Subject: Re: HTML to ASCII
Message-Id: <37EAFC17.E102A8EA@casinofantasy.com>

Actually I'll fix you up on that, run it off your perl script.

$url = "http://www.parsetv.com"; # great internet TV here ;].
$return_data = `lynx -dump $url`;

and $return_data is the var that contians your dreams ;]. But personally, i
hate having to resort to lynx, it's one hell of a bitch ;].



Malcolm Dew-Jones wrote:

> Not perl, nor perfect but -
>
>         lynx -dump (?)
>
> I forget the option, so it may not be -dump, but lynx has various useful
> options, and one of them will save its displayed output in a file.  It
> can even provide a list of "footnotes" which are the URLs seen in the
> document.
>
> Lynx doesn't render tables very well, but at least the data is there.
>
> Cyrille wrote:
> >
> > Hi,
> > I want to converte HTML to ASCII,
> >
> > but modules :
> >     use HTML::FormatText ;
> >     use HTML::Parse;
> >
> > doesn't parse TABLE !
> >
> > Is there a another way ? Another module or script ?
> >
> > Thanx,
> > Cyrille.



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

Date: Thu, 23 Sep 1999 20:28:17 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Pass by reference
Message-Id: <MPG.12548fa8d587a2a4989fd1@nntp.hpl.hp.com>

In article <fqBG3.208$fQ3.4745@nsw.nnrp.telstra.net> on Fri, 24 Sep 1999 
02:33:47 GMT, Martien Verbruggen <mgjv@comdyn.com.au> says...
 ...
> But you can't modify the original array this way, which I believe
> would be what you want, otherwise you wouldn't be passing by
> reference.

That is a strange assumption.  Perhaps you mean it pedagogically.

It is far more efficient to pass a large aggregate by reference than by 
value, even if all one wants to do is to read its contents.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 23 Sep 1999 22:02:04 -0600
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: Pass by reference
Message-Id: <7set3s$6f@llama.swcp.com>

Rick Delaney  <rick.delaney@home.com> wrote:
> Miguel Ortu~o wrote:
> > sub my_function{
> >     my @my_list=@$_[0];
> 
> You want 
> 
>     my @my_list = @{ $_[0] };

Several people have posted the same answer which seems to ignore
the real question -- how to pass by reference and deal with the
"thingies" to which the reference refer.  (The referants
if you lead a joyless existence...)

The statement

	my @my_list = @{$_[0]}

makes a copy of the array that was so carefully passed by
reference in the few lines of code that were elided.  Perhaps
Miguel should use the dereference operator to extract the
items of interest:

	my $arr_ref = shift;
	my $element = $arr_ref->[2];

Or maybe the local operator is more appropriate (and faster) for
his needs:

	local *array = shift;
	my $element = $array[2];

Neither of which make a copy of the array that was passed by reference.
And, as (The Other) Larry pointed out, -w is your friend.  However
in this case no warning is generated for the @$_[0] line in my
version of Perl (5.005_03 built for i386-linux).

Of course -- you may want $_ to be a reference to an empty array...
What ever floats your scalars, man.


Tramm
-- 
  o   hudson@swcp.com                 tbhudso@cs.sandia.gov   O___|   
 /|\  http://www.swcp.com/~hudson/          H 505.323.38.81   /\  \_  
 <<   KC5RNF @ N5YYF.NM.AMPR.ORG            W 505.284.24.32   \ \/\_\  
  0                                                            U \_  | 


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

Date: Fri, 24 Sep 1999 04:38:06 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Pass by reference
Message-Id: <OeDG3.233$fQ3.5885@nsw.nnrp.telstra.net>

In article <MPG.12548fa8d587a2a4989fd1@nntp.hpl.hp.com>,
	lr@hpl.hp.com (Larry Rosler) writes:
> In article <fqBG3.208$fQ3.4745@nsw.nnrp.telstra.net> on Fri, 24 Sep 1999 
> 02:33:47 GMT, Martien Verbruggen <mgjv@comdyn.com.au> says...
> ...
>> But you can't modify the original array this way, which I believe
>> would be what you want, otherwise you wouldn't be passing by
>> reference.
> 
> That is a strange assumption.  Perhaps you mean it pedagogically.

Yeah, yeah, that's it. I was being pedagogic :)

> It is far more efficient to pass a large aggregate by reference than by 
> value, even if all one wants to do is to read its contents.

Indeed, I actually didn't assume he meant to pass enormous arrays
around. My wrong. At least he got, hopefully, a bit more of an insight
about what's going on out of this.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | Little girls, like butterflies, need no
Commercial Dynamics Pty. Ltd.       | excuse - Lazarus Long
NSW, Australia                      | 


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

Date: Fri, 24 Sep 1999 04:41:11 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Pass by reference
Message-Id: <HhDG3.234$fQ3.5885@nsw.nnrp.telstra.net>

In article <7set3s$6f@llama.swcp.com>,
	hudson@swcp.com (Tramm Hudson) writes:

> Several people have posted the same answer which seems to ignore
> the real question -- how to pass by reference and deal with the
> "thingies" to which the reference refer.  (The referants
> if you lead a joyless existence...)

I guess my post didn't make it to your newsfeed yet :)

> 	local *array = shift;
> 	my $element = $array[2];

I think that this should probably get a few big warning labels
attached to it. Don't use typeglobs unless you know what they do. They
can be highly confusing for the unitiated. Don't propagate the use of
typeglobs for these sorts of things. Typeglobs don't work on lexically
scoped variables. Etc.. etc..

Martien
-- 
Martien Verbruggen                  | My friend has a baby. I'm writing down
Interactive Media Division          | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd.       | I can ask him what he meant - Steven
NSW, Australia                      | Wright


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

Date: Thu, 23 Sep 1999 22:34:20 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Pass by reference
Message-Id: <MPG.1254ad23512be756989fd3@nntp.hpl.hp.com>

In article <7set3s$6f@llama.swcp.com> on 23 Sep 1999 22:02:04 -0600, 
Tramm Hudson <hudson@swcp.com> says...
 ...
> 	my $arr_ref = shift;
> 	my $element = $arr_ref->[2];
> 
> Or maybe the local operator is more appropriate (and faster) for
> his needs:
> 
> 	local *array = shift;
> 	my $element = $array[2];

Why would this code, which fails 'use strict;', be more appropriate than 
the first snippet?  How much faster could it be to make it worthwhile?

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 24 Sep 1999 04:37:07 GMT
From: "Karim" <abdelkrim@home.com>
Subject: Perl and Ms Personnal Web server
Message-Id: <TdDG3.1994$3e2.27430@news.rdc1.tn.home.com>

Hi,
I am new to Perl. I have recently downloaded Perl for windows and installed
Microsoft Web Server. I just don't know how to configure Ms Personnal Web
server to jump into Perl programming. Anybody who knows how to do it or has
a detailed documentation I need help.




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

Date: Fri, 24 Sep 1999 05:00:39 GMT
From: bayinnaung@my-deja.com
Subject: Reference of a Slice
Message-Id: <7sf0hj$d3d$1@nnrp1.deja.com>

Reference of a Slice

How do I apply the reference operator "\" to a slice? For example:

Instead of the incorrect:
$combined = &$combiner(&$successors($states->[0]),\@$states[1..$#
{@$states}]);

I use:
push(@rest,@$states[1..$#{@$states}]);
$combined = &$combiner(&$successors($states->[0]),\@rest);

But I feel I could do better...
In this recursive search routine:

sub treesearch {
   my($explored,$goal,$successors,$combiner) = @_;
   my(@rest,@children,@combined,$last,@states,$states);
   @states = @$explored;
   $states = \@states;

   if ($debug > 11) { exit; } else { ++$debug; }
   print "states: ", Dumper($states), "\n";
   if (scalar(@$states) == 0) {
      return 0;
   } elsif (&$goal($states->[0])) {
      return $states->[0];
   } else {
      #$combined = &$combiner(&$successors($states->[0]),\@$states[1..$#
{@$states}]);

      push(@rest,@$states[1..$#{@$states}]);
      $combined = &$combiner(&$successors($states->[0]),\@rest);

      treesearch($combined,$goal,$successors,$combiner);
   }
}

Thanks,

Jon Fernquest
ferni@loxinfo.co.th
bayinnaung@hotmail.com
http://www.geocities.com/SoHo/Square/3472/index.html



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 24 Sep 1999 05:37:52 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Reference of a Slice
Message-Id: <Q6EG3.7666$QJ.483874@typ11.nn.bcandid.com>

In article <7sf0hj$d3d$1@nnrp1.deja.com>,  <bayinnaung@my-deja.com> wrote:
>Reference of a Slice
>
>How do I apply the reference operator "\" to a slice?

Slices are lists, not arrays, so you can't take references to them.
What you can do is copy them into an array and take a reference to that
array.

You may find it more convenient to use an anonymous array --
[@states[1..$#states]] -- instead of using an explicitly named array
created in a separate statement.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 24 Sep 1999 05:25:16 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Regex & URL parsing...
Message-Id: <0XDG3.7655$QJ.490239@typ11.nn.bcandid.com>

In article <fHxG3.783$5t2.11715@news1.rdc1.bc.home.com>,
SHC <sunfox@home.com> wrote:
>I'd like to be able to take all plain URL references in a text string - say
>http://www.microsoft.com/windows/file.htm or www.ibm.com/pc/ and convert
>them to HTML hotlinks - <A HREF="(address)">(address)</A>. I can start the
>regex at http:// or www. easy, but I can't get it to stop at the right
>place.
>
>I'd like it only to ONLY stop the match for a blank space (/s), a !.,?:
>followed by a blank space, two or more of the previous groups of character
>(say if there's a ... or !!!) or a < alone (can be right against the rest of
>the URL; something that's in the data I'm already working with at places).

That's something like (?x: \s | [!.,?]\s | (?:[!.,?]|\s){2,} | < ), isn't it?

That's a little redundant, though; the second case can be eliminated,
for (?x: \s | (?:[!.,?]|\s){2,} | <).  Except you can put the \s inside
the character class, for a nice increase in clarity: (?x: \s |
[!.,?\s]{2,} | <).  Probably faster too.

But in all likelihood, if it's munching up the rest of your line as
part of the RE match, what you want is not a regex to *match* the
terminator, but a regex to match *anything not containing* the
terminator.

So you want a pattern to match "anything not containing blank space or
two or more [\s!.,?] in a row or <".

I end up imagining myself as a state machine walking along the string
here, and trying to figure out what my transition rules are.  They are:
1. if you hit a blank space, stop.
2. if you hit a <, stop.
3. if you hit a [!.,?], then go into a different state.

In the different state, if you hit a [<\s!.,?], stop and throw away the
previous character.  Otherwise go back to the first state.

You can write this out nicely as (?x: [^\s<!.,?] | [!.,?] [^<\s!.,?]
)*.  Well, actually, if you hit the end of the string after a [!.,?],
the [!.,?] won't get included.  This is probably good.

So here's a program that slurps tails like you said.  (Sorry about the
truly inane sample text.)

#!/usr/bin/perl -w
use strict;
$_ = 'this is a re-mark/able.experience.isn\'t.it?' . "\n" .
	'how?bad?can?this.get...pal? wadda ya think?';
print "$&\n" while m{ (?: [^\s<!.,?] | [!.,?] [^<\s!.,?] )+ }gx;

Output:

this
is
a
re-mark/able.experience.isn't.it
how?bad?can?this.get
 .pal
wadda
ya
think

Notes:
- I didn't use (?x: ... ) because it didn't work.  I think I saw something
  posted here about that a couple days ago.
- I used + instead of * because I don't have anything in front of the
  'tail' regex, so the regex would match null strings.  Presumably you
  have something like (http://|www) at the front, so you won't have this
  problem.
- probably a simpler approach would be to use minimal matching (with
  .*? or something) and use the other (untested) regex above to recognize
  the end.  That would probably score points for being straightforward.

>Any ideas? I'm stuck and would appreciate any help or LINKS to tutorials on
>this. No, PerlDoc does not explain this properly for my purposes.... believe
>me, I've tried.

Hope this helps!
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: 23 Sep 1999 23:36:47 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: REQ: tell-a-friend script
Message-Id: <37eb0def@cs.colorado.edu>

In comp.lang.perl.misc, 
    planb@newsreaders.com (J. Moreno) writes:
:I didn't say it wasn't intentional, it's still a typo.

Congratulations: you're an idiot.  When you learn what typo 
means, you'll see why.

--tom
-- 
"A well-written program is its own heaven;
a poorly-written program is its own hell."


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

Date: 24 Sep 1999 01:11:53 -0400
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: Some e-mails get sent, some don't
Message-Id: <7sf16p$las@junior.apk.net>

In article <J5VF3.67$ml3.5445@nsw.nnrp.telstra.net>,
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
>In article <7s8ht6$2cb@junior.apk.net>,
>	catfood@apk.net (Mark W. Schumann) writes:
>
>> My comment: and won't Perl catch these things if you leave taint
>> checking on?  There's a _reason_ for taint checking.
>
>Nono.. That's not what perl's taint checking is about. Perl's taint
>checking is there to warn you about which variables, paths etc may be
>dangerous. It cannot examine the contents of the variables for you,
>because it can't really know what they mean. It can also not examine
>the effects or implications of a full command, because it can't know
>whether that is what you really intended.

And in general, Perl's taint mechanism assumes the worst.

>In the case of open, sure. perl could extrapolate the variables, and
>make a guess about what's safe, and what isn't. But it could be wrong.
>
>open(IN '| some_filter | $mail $addr');
>
>Now... which of these pipes is 'safe' and which isn't? 

They're assumed unsafe by "taint."  Um, right?  The first because
its path isn't specified, the second because of a million reasons.

>Of course it could only look at the contents of $addr, but you may
>still want to have shell characters in there, even though perl might
>now like it. In other words: Anything that perl might _assume_ might
>not be what you want. And if you make that assumption configurable,
>you're back at exactly the same point where we are: You define what's
>safe, and what isn't.
>
>That's why taint mode just tells you what's suspect, and relies on you
>to clean it up.

Right, right, right.

I'm saying that the poster who suggested the problematic code in
the first place would have been straightened out by watching the
error messages from perl -T.



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

Date: Thu, 23 Sep 1999 21:36:39 -0700
From: "Mace" <mace@calweb.com>
Subject: Spell Checker In Perl
Message-Id: <37eb0118_1@news.calweb.com>

Here is a question for you.  I asked one of my very PERL smart friends if it
was possible to make a spell check in perl.  He said yes, but you needed
some kind of moduel.  Does anyone have this, know where I can get it, or how
to make a spell checker?  Please email me.

thanks,

Mace
mace@calweb.com




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

Date: Fri, 24 Sep 1999 05:39:06 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Spell Checker In Perl
Message-Id: <_7EG3.239$fQ3.584@nsw.nnrp.telstra.net>

In article <37eb0118_1@news.calweb.com>,
	"Mace" <mace@calweb.com> writes:
> Here is a question for you.  I asked one of my very PERL smart friends if it
> was possible to make a spell check in perl.  He said yes, but you needed
> some kind of moduel.  Does anyone have this, know where I can get it, or how
> to make a spell checker?

From CPAN: http://www.cpan.org/

There's a module Text::Ispell which just encapsulates the ispell
program. I don't know of any others, but you may be able to find
something when searching CPAN.

>                           Please email me.

No. If your question is important enough for you to post here, and
request from us all to invest time in reading it and answering it,
then it should also be important enough for you to keep an eye on this
newsgroup for a while.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | The gene pool could use a little
Commercial Dynamics Pty. Ltd.       | chlorine.
NSW, Australia                      | 


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

Date: Thu, 23 Sep 1999 23:40:23 -0400
From: David Boyce <dboyce@mediaone.net>
Subject: Re: Using the Expect.pm module w/Perl5.00502
Message-Id: <37EAF2A7.8C728213@mediaone.net>

Mark Jarvis wrote:
>     In general, what I need to do is this:  spawn a process
> and send a few things to the process interactively.  This
> causes the process to generate as much as megabytes of
> text, all of which I log and process off-line.  I look for a pattern
> to indicate that I have all of the text, then nicely close everything
> and exit from the spawned process.  Done.

You might try IPC::ChildSafe instead to do this - it sounds like you're
doing a very similar thing. Can't help with Expect.pm per se, though.

-David Boyce


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

Date: Fri, 24 Sep 1999 04:54:21 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Validating unsafe code?
Message-Id: <1uDG3.7623$QJ.485149@typ11.nn.bcandid.com>

In article <p8AG3.151$fQ3.3535@nsw.nnrp.telstra.net>,
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
>In article <Pine.GSO.4.10.9909231947240.2790-100000@mamba.cs.virginia.edu>,
>	David Coppit <newspost@coppit.orgDIESPAM> writes:
>> Basically, I'm trying to validate Perl modules that people send me,
>> to make sure that they are well-formed and don't contain any
>> dangerous commands that would nuke an unsuspecting user's machine.  
>
>Hmmm. That's a hard job. If you're looking for deliberate dangers,
>you'll have no choice but to read every line of code.

Not necessarily.  The approach David is taking is basically valid; the
program won't hurt anything if all it does is sit and compute.  It's
only where it's interfacing with the rest of the system that it can be
dangerous.

>> I don't need a perfect method, but at least one that can raise
>> flags, and doesn't have any false negatives. If false negatives are
>> impossible to avoid, at least this will help me when I do a manual
>> inspection of the code.
>
>false negatives? As in: I'm warning you that this is dangerous, but in
>reality it's not? Or.. I'm not warning you about this, but it's really
>dangerous?
>
>I suspect you mean the second one. I don't think there is any way in
>which you can avoid either of the two.

You can trivially avoid either: always returning "not dangerous" will
avoid any false positives, and always returning "dangerous" will avoid
any false negatives.

You can do better: if the script is empty, return "not dangerous", else
return "dangerous".

You can refine this further; there will always be *some* errors, unless
you don't mind your checking script running forever, but obvious
refinements include:
- returning "not dangerous" unless the code uses possibly-unsafe 
  operators, functions, or modules
- returning "not dangerous" if the code does use these, but uses them
  in a safe way (e.g. open() with a variable for its second argument may
  not be safe, but open() with a constant string for its second argument
  may be)

Refine to taste.  :)

>> Here are the things I've thought to look for:

Probably doing this thoroughly requires going over perlfunc and perlop
with a fine-toothed comb.  I suspect Andre Merzky has already done this
for Penguin.  Unfortunately, Penguin appears to be two years out of
date (according to http://www.cpan.org/modules/by-module/Penguin/
anyway).

>> system()
>> eval()
>
>not inherently dangerous in perl, unless it contains any of the other
>dangerous ones.

Right -- but you can't tell statically whether it does or not, since
you can eval() a string you create at run time.

>You know that taint mode will warn for many of this stuff, right?

He wants to find out (a) before he runs it and (b) even if the
programmer is trying to conceal it.

>> unlink()
>
>Not sure that this is dangerous, unless it tries to unlink something
>stupid, like /etc/passwd. Don't run it as root, and you will know.

It might just try to unlink all *your* files.  :)

>> Is there an easy way to check for such dangerous commands?
>> "$code =~ s/#[^\n]\bbadcommand\b/s" seems too naive.
>
>I don't think that I would recommend anyone using automated tools to
>do this sort of checking. It's much too easy to fool those.

It is possible to construct an automated tool that will get only false
positives, though.

>Some things you can do are: Run these things never as root. That way
>damage gets limited. Run these things in a chroot jail. That way any
>damage they do to the system is limited to a harmless file system. Run
>these things on a non-critical system. 

Run them in Penguin.

>Of course, the above bit only applies to unices. I don't know if you
>can set up limited or 'safe' environments under other operating
>systems.

Some OSes have better support for jailing than stock Unices.

>Summarising: I do not personally believe that there is a decent way of
>checking. Things that help are perl's taint mode, the debugger, and
>some standard unix environment issues. I doubt that you can write
>anything that will actually save you any time.

You may be right; I'm very interested to hear David's results!
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 24 Sep 1999 00:17:14 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: You should be admired, or What does this have to do with Perl?
Message-Id: <37EAFA55.E23DB275@chaos.wustl.edu>

David Cassell wrote:
> But after you try to be nice to a few confused posters and get nasty
> "YOU SUCK YOU ARROGANT ASSHOLE" e-mails for your efforts, you may
> feel a little differently.

Damn, isn't that the truth? I cruise the crusty old Unix admin groups
for warm fuzzies anymore. 

e.


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

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


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