[9325] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2920 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 20 11:07:15 1998

Date: Sat, 20 Jun 98 08:00:34 -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           Sat, 20 Jun 1998     Volume: 8 Number: 2920

Today's topics:
    Re: 2 questions about lists (M.J.T. Guy)
    Re: ?CGI scripts & Explorer (Michael Rubenstein)
    Re: [Q] On WAKING a sleeping process... (M.J.T. Guy)
        Apache 90 TimeOut <EdHarris@eg-web.com>
        Can't open SDBM file from CGI <mark@witwerswebworks.com>
    Re: Code Efficiency <ebohlman@netcom.com>
        Find::File/Functional programing <xah@shell13.ba.best.com>
    Re: Finding similar text files - an approach <ebohlman@netcom.com>
    Re: first language <judmc123@bellsouth.net>
    Re: first language (Snowhare)
    Re: Flames.... <ebohlman@netcom.com>
    Re: Multiple pipes question andrew@ugh.net.au
        need help with redirect after form submission. <bolland@goodnet.com>
    Re: need help with redirect after form submission. (http://www.mjm.co.uk/software/)
        perl statistics modules? <dontotten@ibm.net>
    Re: perl statistics modules? (Michael Fuhr)
        Problem with space in front of each line of text. <info@purco.qc.ca>
    Re: Problem with space in front of each line of text. <info@purco.qc.ca>
        Random Numbers <minich@globalnet.co.uk>
        Random Numbers <minich@globalnet.co.uk>
    Re: Random Numbers <ljz@asfast.com>
    Re: Random Numbers (Michael Fuhr)
    Re: REVIEW: Perl CGI Programming - No Experience Requir (Frank D. Cringle)
    Re: setuid problem (M.J.T. Guy)
    Re: Sick things to do in foreach loops (M.J.T. Guy)
    Re: the ?PATTERN? match syntax (Ilya Zakharevich)
    Re: the ?PATTERN? match syntax (Larry Rosler)
    Re: the ?PATTERN? match syntax (Ilya Zakharevich)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 20 Jun 1998 13:50:38 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: 2 questions about lists
Message-Id: <6mgene$bpj$1@pegasus.csx.cam.ac.uk>

Larry Rosler <lr@hpl.hp.com> wrote:
>So I think the statement in the documentation (`perldoc perlsyn` or Blue 
>Camel, p. 100):
>
>"If LIST is an actual array (as opposed to an expression returning a list 
>value), you can modify each element of the array by modifying VAR inside 
>the loop.  That's because the foreach loop index is an implicit alias for 
>each item in the list that you're looping over."
>
>should be generalized along these lines:
>
>"If any element in LIST is an lvalue, for example by being a member of an 
>actual array (as opposed to an expression returning a list value), you 
>can modify its value by modifying VAR inside the loop..."
>
>And the examples should include scalars as well as arrays.
>
>If I am correct, please advise whether and how to request a change to the 
>documentation (via perlbug?).

You are correct, but also too late!   perldoc perlsyn in perl5.004_05
reads

     If any element of LIST is an lvalue, you can modify it by
     modifying VAR inside the loop.  That's because the foreach
     loop index variable is an implicit alias for each item in
     the list that you're looping over.

And instructions on submitting patches are contained in the file
Porting/patching.pod in the source tree.   (But only in Perl versions
5.004_05 and later.)


Mike Guy


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

Date: Sat, 20 Jun 1998 14:15:23 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: ?CGI scripts & Explorer
Message-Id: <358ec232.114427838@nntp.ix.netcom.com>

On Sat, 20 Jun 1998 00:56:59 GMT, root.noharvest.\@not_even\here.com
(-) wrote:

>lr@hpl.hp.com (Larry Rosler) Said this:
>
>>In article <358952ED.6CD8CB72@inlink.com>, perlguy@inlink.com says...
>>> Actually there was NOTHING wrong with MY script that I was referring
>>> to.  I DID contact Microsoft and their response was:
>>> 
>>> "We have no interest in fixing it because it is in an old version of the
>>> browser."  (Version 3.02 & 3.03)
>
>This is so sad.  A company that is so much more interested in revenues
>than it is in keeping their current customers happy.  I mean,
>especially coming from a company that is quick to proclaim their
>benevolant concern for the customer and all that marketing blah blah.
>They aren't interested in supporting the one browser that they've
>published that actually has a significant market share, that's utterly
>ridiculous.  Just take a look at how Novell does business.  They are
>much more respectful of their clientelle, maybe even at expense to
>their bottom-line.  I mean, it seems like they issue patches and bug
>fixes to even Netware 3.12 even though they are currently pushing
>"Intranetware".  They even continue to sell 3.12, although obviously
>you wouldn't want to purchase it unless you had certain needs that
>could not be addressed in 4.11 (like if you are connecting to certain
>systems like the airline reservations systems, 3.12 or 2.2 seem to be
>the only ones that work which is a problem in the reservation systems,
>not Netware)

It certainly is sad.  Imagine, a company not fixing an old version.
They probably think that since the new version is free, one should
upgrade.

By the way, where can I get a fix for a bug in Perl 4?  Or do you
expect me to upgrade to a newer version?
--
Michael M Rubenstein


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

Date: 20 Jun 1998 13:59:44 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: [Q] On WAKING a sleeping process...
Message-Id: <6mgf8g$c3p$1@pegasus.csx.cam.ac.uk>

Tom Phoenix  <rootbeer@teleport.com> wrote:
>I'm never sure of anything. :-)  But here's the first part of what
>perlfunc says about sleep:
>
>    Causes the script to sleep for EXPR seconds, or forever if no EXPR.
>    May be interrupted by sending the process a SIGALRM.
>
>As far as portable, I'd say it's sure not going to work on systems that
>don't support signals. But I'd expect it to work on Unix-like systems. 
>(BTW, I believe that other signals work as well as SIGALRM, even though
>the current perl docs don't say so. I seem to recall a docpatch in the
>works on that, and my systems sleep(3c) manpage supports the notion.)

"perldoc -f sleep" in perl5.004_05-to-be will start

Causes the script to sleep for EXPR seconds, or forever if no EXPR.
May be interrupted if the process receives a signal such as SIGALRM.


Mike Guy


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

Date: Sat, 20 Jun 1998 10:46:16 -0400
From: Edward Harris <EdHarris@eg-web.com>
Subject: Apache 90 TimeOut
Message-Id: <358BCB38.5BC4@eg-web.com>

Apache will not allow a perl script to process for more than 90 seconds
without a request. On second 91 it stops the scripts processing and
sends the browser an "Internal Server Error" message.

Does anyone know any code or way to trick Apache into allowing a script
to process for more than 90 seconds?

I posted a simular message before but no one responded with an actual
answer. I have searched for weeks since, but still come up dry.

Thanks

Ed


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

Date: Fri, 19 Jun 1998 19:38:48 -0400
From: Mark Witwer <mark@witwerswebworks.com>
Subject: Can't open SDBM file from CGI
Message-Id: <358AF688.1F0E305C@witwerswebworks.com>

I haven't been able to get my CGI script to open my SDBM file that I
have on my NT server. It is a SDBM file that already exists because I
originally  populated it by running it from the command line. In fact,
if I run the Perl script that attempts to open the same SDBM file  from
the command line, it reports no problems. Every time I execute by
submitting from a form, the browser always reports back my 'die' message
for opening the file. I tried some code I found from a Perl Win32 FAQ
that was on the Perl Language Home page, but that didn't help either.
Anybody got an answer?

Mark Witwer




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

Date: Sat, 20 Jun 1998 06:58:44 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Code Efficiency
Message-Id: <ebohlmanEuu8pw.8pr@netcom.com>

Jim Bowlin <bowlin@sirius.com> wrote:
: I have some suggestions.  Some of these will make it easier for you
: (and others including c.l.p.m) to understand your code which will
: eventually lead to your desired goal of faster run times.

:    1) Use my instead of local.
:    2) Use foreach() instead of for(;;) when you can.
:    3) Make your comments more distinguishable from your code.
:    4) don't bury your main code under an if (open(A, a)) 
:       instead put error code near the open statement.
:    5) Use a hash lookup instead of a long if ... elsif chain.
:    6) Don't keep splitting elements of @entries inside a loop,
:       instead split this stuff once and store it in a structure.
:    7) Read the section on efficency in the Camel Book.

8) Use "here" quoting to generate the HTML.  The existing code suffers 
badly from Leaning Toothpick Syndrome.



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

Date: 20 Jun 1998 07:42:54 -0700
From: Xah Lee <xah@shell13.ba.best.com>
Subject: Find::File/Functional programing
Message-Id: <yo3g1h03zip.fsf@shell13.ba.best.com>


Is there a way to use File::Find with purely functional style programing?
i.e. I want all passing of arguments to be explicit. Since the first
argument to "find" must be a reference (to a function) and the
$File::Find::name is implicitly used, how can I make the passing of
argument ($File::Find::name) to the function explicit?

The following is an example, showing my ideal method.

use File::Find;
find( myFunction($File::Find::name), 'some directory path');
sub myFunction {my $currentFile = $_[0]; {"do something"};
 return "some thing";};

It does not work because the first argument to "find" must be a
reference.

What can I do so that $File::Find::name is passed as an argument
explicitly to myFunction?

(not meant to be inflammable (^_^), but I desire all my codes to be
strickly "functional")

 Xah, xah@best.com
 http://www.best.com/~xah/MathGraphicsGallery_dir/Tiling_dir/tiling.html
 "I love boundage and discipline languages. <wink wink, geek girls>"


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

Date: Sat, 20 Jun 1998 07:35:44 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Finding similar text files - an approach
Message-Id: <ebohlmanEuuAFK.BA6@netcom.com>

Dan Lucas <dlucas@deletethis.gol.com> wrote:

: I have a need to find duplicate text files in a folder. The catch is
: that they will not be identical, just very similar; essentially these
: represent email 'clippings' from sources such as the newswires. Thus,
: while the opening and closing few lines may be different, the 'body'
: is often substantially the same.

This is the exact same thing that a spam-detector program does, if you 
stop to think about it.  You might want to do a search for source code to 
either spam detectors or spam filters, since their authors have had to 
cope with all the various ways that spammers can "minimally customize" 
their junk.



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

Date: Sat, 20 Jun 1998 13:57:40 GMT
From: "Judson McClendon" <judmc123@bellsouth.net>
Subject: Re: first language
Message-Id: <odPi1.3807$RS.3390143@news3.atl.bellsouth.net>

Cyrand wrote:
>
>As a novice programmer, ...
<snip>
>I was nervous about using pointers, and so had trouble using them
>the first few times.  After a few uses, I realized that they were
>more useful than they said, and less tricky.
<snip>

There is a real connection here.  If you don't think C pointers are
'tricky', it just means you haven't used them enough to be bitten by
their subtleties. :-)
-- 
Judson McClendon          This is a faithful saying and worthy of all
Sun Valley Systems        acceptance, that Christ Jesus came into the
judmc123@bellsouth.net    world to save sinners  (1 Timothy 1:15)
(please remove numbers from email id to respond)




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

Date: 20 Jun 1998 14:29:39 GMT
From: snowhare@devilbunnies.org (Snowhare)
Subject: Re: first language
Message-Id: <6mgh0j$6o9$1@supernews.com>



Nothing above this line is part of the signed message.

In article <6me68f$ijt$1@client3.news.psi.net>,
Abigail <abigail@fnx.com> wrote:
>That sounds as if programming would be an art. I disagree with that.
>I believe that most people can be able to learn how to program. Just
>like most people could learn how to become a car mechanic.
>
>Whether everyone has the motivation to learn is a different issue.

You've stepped right into one of the oldest debates in programming. 
I am on the programming as an art side.  I can teach a person all 
about the abstractions, the techniques, the theory and practice - 
but I can't give them the 'spark' that is the difference between 
what I'll call a 'cookbook' programmer and a 'chef' programmer. 

'Cookbook' programmers can follow the recipies, answer the test 
questions and often do adequate maintenance programming where the
basic problem has already been solved. But don't ask them to start 
with a blank screen and a problem of significant proportions and 
successfully design a fast, elegant and well written system that
can be maintained easily. They can't. Their minds don't work that 
way. It requires the ability to literally _think_ in a programming
language with a high degree of creativity and absolute precision. 

The 'chef' progammers are the ones who _write_ the recipies. 

In 18 years of programming, I've run into only a handful of
'chef' programmers.

Benjamin Franz


Version: 2.6.2

iQCVAwUBNYvNkujpikN3V52xAQFjVQQAjYcWxhaoyMJIR56KRHJaRYqPR3iC0kjV
2W3gz+hYOyMzw+HOu7atME+sPqAy6swe+ZKylnExEv58mA0/Me4d9THDp8aN1Ys3
IXAv1wLj6f1jCiZ/CcwQwIBEdruIaqkOD6XHNcBdfWDJ/GUKXPHfv3UWucLlRDly
u6px3QnAhO8=
=Yl9e
-----END PGP SIGNATURE-----


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

Date: Sat, 20 Jun 1998 07:11:40 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Flames....
Message-Id: <ebohlmanEuu9BG.9uy@netcom.com>

John Call <johnc@interactive.ibm.com> wrote:
: There are many reasons for looking in the faqs. First you will find your
: answer. Second, you will find out things you didn't know that don't apply
: directly right now but will in the future. Third, it makes you more
: independent.

Fourth, there's a much greater probability that you'll get a *correct* 
answer (I don't count answers that only work under special cases as 
correct).  Answers in FAQs have been heavily scrutinized and reviewed.



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

Date: Sat, 20 Jun 1998 23:27:53 +1000
From: andrew@ugh.net.au
To: Joshua Swink <mongoose@mail.unlimited.net>
Subject: Re: Multiple pipes question
Message-Id: <Pine.BSF.3.96.980620232725.21699G-100000@house.key.net.au>



On Fri, 19 Jun 1998, Joshua Swink wrote:

> Problem is, if you want to check for user input, the program stops
> until there IS user input.
> 
> Conversely, if you check for text from the MUD, the program stops
> until there IS text from the MUD.

Try using fork and have one process to do one job.

Andrew



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

Date: Sat, 20 Jun 1998 02:28:59 -0700
From: Bolland <bolland@goodnet.com>
Subject: need help with redirect after form submission.
Message-Id: <Pine.GSO.3.95.980620021804.12172A-100000@goodguy.goodnet.com>


I use the add-a-link and guestbook from matts script
archive. I want to add and change redirection after the
forms are submitted. The guestbook currently redirects to a
thank you page. And the add-a-link does not. What I want to
do is this...

Visitor signs the guestbook.
Then after submission they are redirected to add-a-link to
see if they would like to add a link. If they do, I want to
have a  screen come up after their submission that thanks
them for adding a link.

I know which varriable to change in the guestbook to call
the thank you page, but I am switching the add-a-link to a
searchable script that calls a CGI file not an HTML file.
Can this be done???

Then I also need to know how to add the redirect line
pointing to a thank you page after they have pressed submit.
I seem to remember that this is dont by adding something to
the FORM method=post line, but I am not sure, and definately
do not remember how it was done.

Any help would be appreciated. Thanks.
please reply by email as well as to group.

reply to: prozac@mindless.com
http://www.prozacssanitarium.home.ml.org




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

Date: Sat, 20 Jun 1998 12:51:40 GMT
From: mikem@netcomuk.co.uk (http://www.mjm.co.uk/software/)
Subject: Re: need help with redirect after form submission.
Message-Id: <358baf8a.1396493@nntp.netcom.net.uk>

Hi,

Look through the scripts until you find a line starting;

print "Location: $linksurl\n\n";

change the variable $linksurl to where you want the user to be taken
once the guestbook is signed..

note that this line should be before any;
print "content-type: text/html\n\n";

otherwise the line will just print out on the screen.

Hope this helps,

Mike..

http://www.mjm.co.uk/software/


On Sat, 20 Jun 1998 02:28:59 -0700, Bolland <bolland@goodnet.com>
wrote:

>
>I use the add-a-link and guestbook from matts script
>archive. I want to add and change redirection after the
>forms are submitted. The guestbook currently redirects to a
>thank you page. And the add-a-link does not. What I want to
>do is this...
>
>Visitor signs the guestbook.
>Then after submission they are redirected to add-a-link to
>see if they would like to add a link. If they do, I want to
>have a  screen come up after their submission that thanks
>them for adding a link.
>
>I know which varriable to change in the guestbook to call
>the thank you page, but I am switching the add-a-link to a
>searchable script that calls a CGI file not an HTML file.
>Can this be done???
>
>Then I also need to know how to add the redirect line
>pointing to a thank you page after they have pressed submit.
>I seem to remember that this is dont by adding something to
>the FORM method=post line, but I am not sure, and definately
>do not remember how it was done.
>
>Any help would be appreciated. Thanks.
>please reply by email as well as to group.
>
>reply to: prozac@mindless.com
>http://www.prozacssanitarium.home.ml.org
>
>



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

Date: Sat, 20 Jun 1998 09:14:51 -0700
From: <dontotten@ibm.net>
Subject: perl statistics modules?
Message-Id: <358bb606.0@news1.ibm.net>

Can someone point me to a set of statistical analysis modules written in
perl?

Thx.




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

Date: Sat, 20 Jun 1998 14:21:19 GMT
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: perl statistics modules?
Message-Id: <6mgggo$b4q@flatland.dimensional.com>

<dontotten@ibm.net> writes:

> Can someone point me to a set of statistical analysis modules written in
> perl?

There are hundreds of useful modules on the Comprehensive Perl
Archive Network (CPAN).  Here are some entry points:

    http://www.perl.com/CPAN/CPAN.html
    http://www.perl.com/CPAN/modules/01modules.index.html

Yes, there are some statistical analysis modules.

-- 
Michael Fuhr
http://www.dimensional.com/~mfuhr/


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

Date: Sat, 20 Jun 1998 14:41:52 GMT
From: Leon Stepanian <info@purco.qc.ca>
Subject: Problem with space in front of each line of text.
Message-Id: <358BCBA2.553DC15B@purco.qc.ca>


--------------CAE9B9EDEBFC4746E6AB1911
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

I tried and tried but can't figure this one out.

I'm writting a Perl script to handle a fairly elaborate trading system.
In one portion of the script users can paste their sales contract into a
text field and save this to a seperate file who's file name is generated
and saves onto another file. The user can re-open the contract anytime
to modify and re-save, but here's the problem.

Let's say the file containing the contract is 123456789.con and it has
this text which was successfully saved to it;
# start of file
This is a first line.

This is a third line.

This is a fifth line.

This is a seventh line.

This is a ninth line.

This is the last line just entered to do a final check.
# end of file

All lines are properly left aligned inthe saved file.

Now when i read this file back into the text area, this is what happens.

# start of file
This is a first line.

 This is a third line.

 This is a fifth line.

 This is a seventh line.

 This is a ninth line.

 This is the last line just entered to do a final check.
# end of file

Besides the first line, the other lines have a space in front which is
obviously not desirable. Originally I had the standard open<xxx>,
print<xxx>, close<xxx> routine which did the same problem, so I decided
to split the file into lines and work on them seperately to see what
happens, but the same problem occurs.

Here is my a simplified portion of script since without the many
conditionals which are working just fine.

if(open(CONTRACT, "$messages/$postlist[$slide][9].con"))
    {
    print "$messages/$postlist[$slide][9].con<BR>";
#    $cutout1=chomp(@holdfile); #tried chomp but no effect
    $zittle=0;
    while(<CONTRACT>)
    {
    #put the file into @holdfile array, line by line
    @holdfile[$zittle]=split(/\n/o, $_);
    #if one or more spaces at beggining on line, remove it or them
    @holdfile[$zittle]=~ s/^ +//g; #I tried many many variations of
this.
    }
    close<CONTRACT>;
# provide @holdfile to the html portion for printing and the saving to
file afterwards.
print "<TEXTAREA COLS=70 ROWS=20
name=\"c_text\">@holdfile</TEXTAREA>\n";

I think the problem has to do with trailing line but I can't get this
resolved after two days of tinkering. After 200k of scripting this Perl
progam, this one problem has me blocked.

Any help????????

Leon Stepanian
Perl.................from an ocean of human kinds.

--------------CAE9B9EDEBFC4746E6AB1911
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
<TT>Hi,</TT><TT></TT>

<P><TT>I tried and tried but can't figure this one out.</TT><TT></TT>

<P><TT>I'm writting a Perl script to handle a fairly elaborate trading
system. In one portion of the script users can paste their sales contract
into a text field and save this to a seperate file who's file name is generated
and saves onto another file. The user can re-open the contract anytime
to modify and re-save, but here's the problem.</TT><TT></TT>

<P><TT>Let's say the file containing the contract is 123456789.con and
it has this text which was successfully saved to it;</TT>
<BR><TT># start of file</TT>
<BR><TT>This is a first line.</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>This is a third line.</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>This is a fifth line.</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>This is a seventh line.</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>This is a ninth line.</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>This is the last line just entered to do a final check.</TT>
<BR><TT># end of file</TT><TT></TT>

<P><TT>All lines are properly left aligned inthe saved file.</TT><TT></TT>

<P><TT>Now when i read this file back into the text area, this is what
happens.</TT><TT></TT>

<P><TT># start of file</TT>
<BR><TT>This is a first line.</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>&nbsp;This is a third line.</TT><TT></TT>

<P><TT>&nbsp;This is a fifth line.</TT><TT></TT>

<P><TT>&nbsp;This is a seventh line.</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>&nbsp;This is a ninth line.</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>&nbsp;This is the last line just entered to do a final check.</TT>
<BR><TT># end of file</TT><TT></TT>

<P><TT>Besides the first line, the other lines have a space in front which
is obviously not desirable. Originally I had the standard open&lt;xxx>,</TT>
<BR><TT>print&lt;xxx>, close&lt;xxx> routine which did the same problem,
so I decided to split the file into lines and work on them seperately to
see what happens, but the same problem occurs.</TT><TT></TT>

<P><TT>Here is my a simplified portion of script since without the many
conditionals which are working just fine.</TT><TT></TT>

<P><TT>if(open(CONTRACT, "$messages/$postlist[$slide][9].con"))</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; {</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; print "$messages/$postlist[$slide][9].con&lt;BR>";</TT>
<BR><TT>#&nbsp;&nbsp;&nbsp; $cutout1=chomp(@holdfile); #tried chomp but
no effect</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; $zittle=0;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; while(&lt;CONTRACT>)</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; {</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; #put the file into @holdfile array, line by
line</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; @holdfile[$zittle]=split(/\n/o, $_);</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; #if one or more spaces at beggining on line,
remove it or them</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; @holdfile[$zittle]=~ s/^ +//g; #I tried many
many variations of this.</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; }</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; close&lt;CONTRACT>;</TT>
<BR><TT># provide @holdfile to the html portion for printing and the saving
to file afterwards.</TT>
<BR><TT>print "&lt;TEXTAREA COLS=70 ROWS=20 name=\"c_text\">@holdfile&lt;/TEXTAREA>\n";</TT><TT></TT>

<P><TT>I think the problem has to do with trailing line but I can't get
this</TT>
<BR><TT>resolved after two days of tinkering. After 200k of scripting this
Perl progam, this one problem has me blocked.</TT><TT></TT>

<P><TT>Any help????????</TT><TT></TT>

<P><TT>Leon Stepanian</TT>
<BR><TT>Perl.................from an ocean of human kinds.</TT></HTML>

--------------CAE9B9EDEBFC4746E6AB1911--



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

Date: Sat, 20 Jun 1998 14:49:19 GMT
From: Leon Stepanian <info@purco.qc.ca>
Subject: Re: Problem with space in front of each line of text.
Message-Id: <358BCD61.A32C85CC@purco.qc.ca>


--------------83DFD7C1C27F2FAECF058AA6
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

(snipped)

Sorry, made an error. This line

    @holdfile[$zittle]=~ s/^ +//g; #I tried many many variations of
this.

should read

    @holdfile[$zittle++]=~ s/^ +//g; #I tried many many variations of
this.

Thank in advance

Leon Stepanian

Perl.................from an ocean of human kinds.


--------------83DFD7C1C27F2FAECF058AA6
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
(snipped)

<P>Sorry, made an error. This line

<P><TT>&nbsp;&nbsp;&nbsp; @holdfile[$zittle]=~ s/^ +//g; #I tried many
many variations of this.</TT>

<P>should read

<P><TT>&nbsp;&nbsp;&nbsp; @holdfile[$zittle++]=~ s/^ +//g; #I tried many
many variations of this.</TT>

<P>Thank in advance<TT></TT>

<P><TT>Leon Stepanian</TT><TT></TT>

<P><TT>Perl.................from an ocean of human kinds.</TT>
<BR>&nbsp;</HTML>

--------------83DFD7C1C27F2FAECF058AA6--



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

Date: Sat, 20 Jun 1998 14:34:00 +0100
From: "Martin" <minich@globalnet.co.uk>
Subject: Random Numbers
Message-Id: <6mgdnn$87h$1@heliodor.xara.net>

Can anyone PLEASE help? I want to be able to choose a random number between
1 and 10 but don't know how to do it in Perl. I thought about using the $^T
variable for a sort of random number - or close enough! does anyone know how
to get the least significant number of a number. In BASIC, you could use:

a$ = right$(test$,1)

How can this be done in Perl?

Thanx!




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

Date: Sat, 20 Jun 1998 15:40:23 +0100
From: "Martin" <minich@globalnet.co.uk>
Subject: Random Numbers
Message-Id: <6mghk6$dd5$1@heliodor.xara.net>

Thanks for your help!

Martin




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

Date: 20 Jun 1998 10:11:48 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Random Numbers
Message-Id: <ltra0kw4bf.fsf@asfast.com>

"Martin" <minich@globalnet.co.uk> writes:

> Can anyone PLEASE help? I want to be able to choose a random number between
> 1 and 10 but don't know how to do it in Perl. I thought about using the $^T
> variable for a sort of random number - or close enough! does anyone know how
> to get the least significant number of a number. In BASIC, you could use:
> 
> a$ = right$(test$,1)
> 
> How can this be done in Perl?

Perl has a `rand' function that returns a random number.  If passed a
positive argument `N', it returns a random value `V' such that ...

   0.0 <= V < N

If passed no argument, it returns a value 'V' such that ...

   0.0 <= V < 1.0

Do a `man perlfunc' and look for `rand' for more necessary details about
this function; or do a `perldoc -f rand'.

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: Sat, 20 Jun 1998 14:17:44 GMT
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Random Numbers
Message-Id: <6mgga4$b2l@flatland.dimensional.com>

"Martin" <minich@globalnet.co.uk> writes:

> Can anyone PLEASE help? I want to be able to choose a random number between
> 1 and 10 but don't know how to do it in Perl. I thought about using the $^T
> variable for a sort of random number - or close enough! does anyone know how
> to get the least significant number of a number. In BASIC, you could use:
>
> a$ = right$(test$,1)
>
> How can this be done in Perl?

This can be done in Perl by reading the documentation.  Try the
perlfunc manual page.

-- 
Michael Fuhr
http://www.dimensional.com/~mfuhr/


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

Date: Sat, 20 Jun 1998 11:19:46 GMT
From: fdc@cliwe.ping.de (Frank D. Cringle)
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <vtvhpw5nhp.fsf@cliwe.ping.de>

c.c.eiftj@54.usenet.us.com (Rahul Dhesi) writes:
> I believe some of the confusion arises because the word 'list' is used
> both for lists as rvalues and as lvalues.  If we had a new word such as
> 'varlist' for a list when used on the LHS, we would have a cleaner set
> of defintions.

There is no requirement for the elements to be all lvalues or all
rvalues.  Is ($a, 1, $b, 2) a list or a varlist?

A list is a fixed-length anonymous ordered set of values.  An array is
a named variable-length ordered set of anonymous variables.  The term
'value' used to describe the elements of lists encompasses constants,
variables and the results of evaluating expressions.  In perl, some
expressions evaluate to an lvalue - e.g. $cond ? $a : $b.  You can
assign to a list if all of its elements are mutable in this sense.
You can always assign to an array.

-- 
Frank Cringle,      fdc@cliwe.ping.de
voice: (+49 2304) 467101; fax: 943357


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

Date: 20 Jun 1998 14:28:21 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: setuid problem
Message-Id: <6mggu5$d5o$1@pegasus.csx.cam.ac.uk>

Zach Malchano  <zjm@fast-inc.com> wrote:
>I'm in the process of writing a setuid/setgid program, but I'm having a
>large problem w/ taint checking. The program gets a username and
>password via CGI (html form), but will not allow a file handle:
>
>$path = "/home/$username/www/index.html";
>$fh = new FileHandle "$path", "w" or die "Can't open $!\n";

And just as well too.    What if $username had the value '../etc/passwd' ?

See perldoc perlsec for information on how to check tainted values, and how
to get untainted values from tainted ones.


Mike Guy


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

Date: 20 Jun 1998 14:34:53 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Sick things to do in foreach loops
Message-Id: <6mghad$d9r$1@pegasus.csx.cam.ac.uk>

Peter Scott <psf@euclid.jpl.nasa.gov> wrote:
>I had a reason to want to extend the list in a foreach loop, and
>to my pleasant surprise, I found that I could actually push elements
>onto the end of the list while in the loop and still have the loop
>iterate over them.  It's not clear to me that this would be implied
>by the fact that the loop element was an alias for the actual list
>element.  So, for instance:

perldoc perlsyn tells you:

     If any part of LIST is an array, foreach will get very
     confused if you add or remove elements within the loop body,
                     ^^^
     for example with splice.   So don't do that.

So you deserve all you get.   But perhaps not SEGVs  -  that's a bug
which ought to be fixed.


Mike Guy


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

Date: 20 Jun 1998 07:42:06 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: the ?PATTERN? match syntax
Message-Id: <6mfp4e$o8o$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Larry Rosler
<lr@hpl.hp.com>],
who wrote in article <MPG.ff4f872f1741ea09896d4@nntp.hpl.hp.com>:
> I discovered that one cannot include a literal question-mark character in 
> an RE delimited by ??, no matter how many backslashes are used to escape 
> it.  Ilya Zakharevich confirmed this arcane syntactic anomaly (bug).  
> Amazing that it has not been encountered until now.  NOT!

This is not a bug.  Just a restriction.  Similarly, you cannot easily
match literal C<*> in m*...*.

Ilya


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

Date: Sat, 20 Jun 1998 01:26:49 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: the ?PATTERN? match syntax
Message-Id: <MPG.ff5121f42e6ec4a9896d5@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <6mfp4e$o8o$1@mathserv.mps.ohio-state.edu>, Ilya Zakharevich 
<ilya@math.ohio-state.edu> says...
> [A complimentary Cc of this posting was sent to Larry Rosler
> <lr@hpl.hp.com>],
> who wrote in article <MPG.ff4f872f1741ea09896d4@nntp.hpl.hp.com>:
> > I discovered that one cannot include a literal question-mark character in 
> > an RE delimited by ??, no matter how many backslashes are used to escape 
> > it.  Ilya Zakharevich confirmed this arcane syntactic anomaly (bug).  
> > Amazing that it has not been encountered until now.  NOT!
> 
> This is not a bug.  Just a restriction.  Similarly, you cannot easily
> match literal C<*> in m*...*.

Ah.  *Finally* I see the rule:  One cannot 'easily' represent a literal 
character in an RE delimited by that same character if the character is 
in the set of single-character quantifiers ?*+  .  Clearly not a bug, but 
hardly a feature :-).  Also, very likely not documented anywhere.

And 'easily' means that though it can't be done via escapes, one *can* 
slip the match character into the RE via interpolation.  Whew!!!

Thanks for helping me through this.  I am catching little glimpses of the 
inner mechanisms of this intricate machine.

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


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

Date: 20 Jun 1998 08:43:37 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: the ?PATTERN? match syntax
Message-Id: <6mfsnp$22u$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Larry Rosler
<lr@hpl.hp.com>],
who wrote in article <MPG.ff5121f42e6ec4a9896d5@nntp.hpl.hp.com>:
> > > I discovered that one cannot include a literal question-mark character in 
> > > an RE delimited by ??, no matter how many backslashes are used to escape 
> > > it.  Ilya Zakharevich confirmed this arcane syntactic anomaly (bug).  
> > > Amazing that it has not been encountered until now.  NOT!
> > 
> > This is not a bug.  Just a restriction.  Similarly, you cannot easily
> > match literal C<*> in m*...*.
> 
> Ah.  *Finally* I see the rule:  One cannot 'easily' represent a literal 
> character in an RE delimited by that same character if the character is 
> in the set of single-character quantifiers ?*+  .  Clearly not a bug, but 
> hardly a feature :-).  Also, very likely not documented anywhere.
> 
> And 'easily' means that though it can't be done via escapes, one *can* 
> slip the match character into the RE via interpolation.  Whew!!!

You may also use nice-looking ?[\?]?.  1/2  ;-)

Ilya


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

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

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