[16461] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3873 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 1 18:05:51 2000

Date: Tue, 1 Aug 2000 15:05:25 -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: <965167525-v9-i3873@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 1 Aug 2000     Volume: 9 Number: 3873

Today's topics:
        Beginner CGI question (lliacopo)
    Re: Beginner CGI question <templar318@earthlink.net>
    Re: check if $sth->fetch is empty <mikek@worldwebserver.com>
    Re: Convert 1000000 --> 1.000.000 (Abigail)
        Copy a hash and const? <blavender@spk.usace.army.mil>
    Re: DBI:: UPDATE format (Perl DBI O'Reilly fails to exp <linux@worsdall.demon.co.uk>
    Re: DBI:: UPDATE format (Perl DBI O'Reilly fails to exp <linux@worsdall.demon.co.uk>
    Re: DBI:: UPDATE format (Perl DBI O'Reilly fails to exp <linux@worsdall.demon.co.uk>
    Re: DBI:: UPDATE format (Perl DBI O'Reilly fails to exp (Logan Shaw)
    Re: DBI:: UPDATE format (Perl DBI O'Reilly fails to exp <linux@worsdall.demon.co.uk>
        Detecting end of HTTP reply <T.Cockle@staffs.ac.uk>
    Re: downloading a file from a remote machine <whitetigercat@home.com>
    Re: Dynamic String to hash <mauldin@netstorm.net>
    Re: forking and child processes <tim@ipac.caltech.edu>
    Re: forking and child processes (matt venn)
    Re: forking and child processes <billy@arnis-bsl.com>
        How to show "tail -f" in browser <mabios@t-online.de>
    Re: How to show "tail -f" in browser <tim@ipac.caltech.edu>
        htaccess and cgi script slandman@my-deja.com
    Re: htaccess and cgi script <memmett@fraser.sfu.ca>
    Re: I have an idea but will it work ? <mjcarman@home.com>
    Re: I have an idea but will it work ? <care227@attglobal.net>
    Re: INfo on the environment variables (David W. Crawford)
        killing process 1 <haggi@tappe.net>
        killing process <haggi@tappe.net>
    Re: killing process <billy@arnis-bsl.com>
    Re: killing process <haggi@tappe.net>
    Re: Newbie question: # of characters in a string (Jon S.)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 01 Aug 2000 20:13:04 GMT
From: Lucas (lliacopo) <lliacopo8088@my-deja.com>
To: lliacopo@insight.com
Subject: Beginner CGI question
Message-Id: <8m7b0a$cn8$1@nnrp1.deja.com>

Hello,

I'm creating a form that is basically a voting ballot. I'd like to know
if there is an airtight way of preventing users from voting more than
once.

--
Thanks! :)




PS: to the idiot who thinks I'm doing my homework: don't reply to this
idiot!



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


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

Date: Tue, 01 Aug 2000 20:37:30 GMT
From: David Tsai <templar318@earthlink.net>
Subject: Re: Beginner CGI question
Message-Id: <398734E0.1B16406A@earthlink.net>


The most "airtight" way would be to make your users register and make them
confirm their email address.  That can be a hassle and would probably make
most of your users just not participate in your poll.  The only other
hassle free ways for your users is to use cookies and log their ip.
However, most users will have dynamic IP addresses so cookies with
temperary IP logging would be the best way to do it.

> Hello,
>
> I'm creating a form that is basically a voting ballot. I'd like to know
> if there is an airtight way of preventing users from voting more than
> once.
>
> --
> Thanks! :)
>
> PS: to the idiot who thinks I'm doing my homework: don't reply to this
> idiot!
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

--

Best Regards,
David Tsai
CGI Paradise
http://www.web-consult.com/scripts/




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

Date: Tue, 01 Aug 2000 18:19:06 GMT
From: "Mike King @work" <mikek@worldwebserver.com>
Subject: Re: check if $sth->fetch is empty
Message-Id: <398714A4.C1C5E6C0@worldwebserver.com>

if ($sth->fetch)    # returns true if not empty
if (! $sth->fetch)   # returns true if empy

-Mike K.

vnguyen_1999@my-deja.com wrote:
> 
> Hello !!!
> 
> How can I check if $sth->fetch is empty?
> 
> Thanks
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.


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

Date: 01 Aug 2000 14:37:23 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Convert 1000000 --> 1.000.000
Message-Id: <slrn8oe66m.vcg.abigail@alexandra.foad.org>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDXXVII
September MCMXCIII in <URL:news:8m63bi$f77$1@lublin.zrz.tu-berlin.de>:
@@ Abigail <abigail@foad.org> wrote in comp.lang.perl.misc:
@@ 
@@ >Which tr/// expression is equivalent with s/\.$//g (which as a pointless /g)?
@@ 
@@ substr( $_, -1) =~ tr/.//d;


    my $foo = "I don't think so.\n";

    $_ = $foo; s/\.$//g;                   my $result1 = $_;
    $_ = $foo; substr ($_, -1) =~ tr/.//d; my $result2 = $_;

    print "Bzzzt. Wrong. Thanks for playing.\n" unless $result1 eq $result2;


Abigail
-- 
               split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_)  {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};


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

Date: Tue, 01 Aug 2000 20:57:00 GMT
From: Brian Lavender <blavender@spk.usace.army.mil>
Subject: Copy a hash and const?
Message-Id: <8m7dip$etk$1@nnrp1.deja.com>

I have the following code which has a subroutine that works on a hash
that is passed to it. I first tried passing the hash to the sub
key_remove, but that would not work, so I tried passing a reference. I
discovered though, that if I modified the hash in the subroutine, that
it modified the original hash in main. I would like to make a copy of
this hash, and leave the original hash in main untouched.

Is the following a good way to make a copy of the hash passed to the
subroutine? Is there a way to specify const for the hash reference
passed to subroutine?

brian

#!/usr/local/bin/perl -Tw

use strict;

my %foo = ('father','barney','mother','betty','child','pebbles');

print "The beginning\n\n";

foreach (keys %foo) {
  print "Key: $_ Value: $foo{$_}\n";
}

print "Call key_remove which prints family except the child \n\n";

key_remove(\%foo);

print "\n Back in Main\n";
print "Is pebbles gone?\n\n";

foreach (keys %foo) {
  print "Key: $_ Value: $foo{$_}\n";
}

sub key_remove {
  # Can I make $family so it stays constant?
  my $family = shift;
  # Make a copy of %$family
  # Is this good?
  my %cp_family = %$family;

  delete $cp_family{'child'};
  foreach (keys %cp_family) {
    print "Sub Key: $_ Value: $cp_family{$_}\n";
  }
  return (0);
}

--
Brian E. Lavender
US Army Corps of Engineers -- Programmer / Systems Analyst
Sacramento, CA    (916) 557-6623


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


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

Date: Tue, 1 Aug 2000 21:49:02 +0100
From: Mark Worsdall <linux@worsdall.demon.co.uk>
Subject: Re: DBI:: UPDATE format (Perl DBI O'Reilly fails to explain properly)
Message-Id: <fuWrs5A+ezh5EwlO@worsdall.demon.co.uk>

In article <8m58gq$8u9$1@provolone.cs.utexas.edu>, Logan Shaw
<logan@cs.utexas.edu> writes
>In article <e9Lb4WAKUgh5EwUH@worsdall.demon.co.uk>,
>Mark Worsdall  <linux@worsdall.demon.co.uk> wrote:
>>Hi,
>>
>>is this wrong:-
>>
>>
>>$sth = $dbh->prepare("UPDATE counter FROM wizSearches WHERE ID =
>>$chkfound");
>>
>>$sth->execute();
>>
>>
>>err, uhm, where do things go?
>>
>>
>>wizSearches is the name of the MySQL table
>>
>>The record to update is ID (the value of $chkfound)
>>
>>This record contains a table field called counter
>>
>>$searchCounter contains the value to stick in the field counter.
>>
>>
>>a) I can't get the syntax right
>>b) where do I stick the new value $searchCounter
>
>Ultimately, you want to run some SQL that looks like this:
>
>       update wizSearch set counter=12345 where ID=67890
>
>There are two ways to do this in perl.  One is to build SQL that
>contains the actual numbers, and the other way is to use placeholders.
>
>The first way would look like this:
>
>       $sth = $dbh->prepare ("update wizSearch set counter=" .
>               $dbh->quote ($searchCounter) . " where ID=" .
>               $dbh->quote ($chkfound) );
>       $sth->execute;
>
>The second way would look like this:
>
>       $sth = $dbh->prepare ("update wizSearch set counter=? where ID=?")
>               or die "blah blah blah";
>       $sth->execute ($searchCounter, $chkfound);
>
>Personally, I find the second method much cleaner.
>
2nd method looks clearer to me too. Thanks. So set was the key.

-- 
He came from Econet - Oh no, I've run out of underpants :(
Home:- jaydee@wizdom.org.uk       http://www.wizdom.org.uk
Shadow:- webmaster@shadow.org.uk  http://www.shadow.org.uk
Work:- netman@hinwick.demon.co.uk http://www.hinwick.demon.co.uk
Web site Monitoring:-             http://www.shadow.org.uk/SiteSight/


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

Date: Tue, 1 Aug 2000 21:54:39 +0100
From: Mark Worsdall <linux@worsdall.demon.co.uk>
Subject: Re: DBI:: UPDATE format (Perl DBI O'Reilly fails to explain properly)
Message-Id: <$+ajoSBPkzh5Ewgs@worsdall.demon.co.uk>

In article <3986572C.242@yahoo.com>, Mouse <glodalec@yahoo.com> writes
>Mark Worsdall wrote:
>> 
>> Hi,
>> 
>> is this wrong:-
>> 
>> $sth = $dbh->prepare("UPDATE counter FROM wizSearches WHERE ID =
>> $chkfound");
>> 
>> $sth->execute();
>> 
>> err, uhm, where do things go?
>> 
>> wizSearches is the name of the MySQL table
>> 
>> The record to update is ID (the value of $chkfound)
>> 
>> This record contains a table field called counter
>> 
>> $searchCounter contains the value to stick in the field counter.
>> 
>> a) I can't get the syntax right
>> b) where do I stick the new value $searchCounter
>> 
>> I have Perl DBI, but strangely it only tells you how to do updates from
>> the command line?
>> 
>Which Page ?

73 & 74

-- 
He came from Econet - Oh no, I've run out of underpants :(
Home:- jaydee@wizdom.org.uk       http://www.wizdom.org.uk
Shadow:- webmaster@shadow.org.uk  http://www.shadow.org.uk
Work:- netman@hinwick.demon.co.uk http://www.hinwick.demon.co.uk
Web site Monitoring:-             http://www.shadow.org.uk/SiteSight/


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

Date: Tue, 1 Aug 2000 22:05:26 +0100
From: Mark Worsdall <linux@worsdall.demon.co.uk>
Subject: Re: DBI:: UPDATE format (Perl DBI O'Reilly fails to explain properly)
Message-Id: <juckMLAWuzh5EwiG@worsdall.demon.co.uk>

In article <8m58gq$8u9$1@provolone.cs.utexas.edu>, Logan Shaw
<logan@cs.utexas.edu> writes
>
>       $sth = $dbh->prepare ("update wizSearch set counter=? where ID=?")
>               or die "blah blah blah";
>       $sth->execute ($searchCounter, $chkfound);
>

So if I was updating a 2nd field then it would be like this?

$sth = $dbh->prepare ("update wizSearch set counter=?, last=? where
ID=?") or die "blah blah blah";
$sth->execute ($searchCounter, $last_date, $chkfound);


OR


$sth = $dbh->prepare ("update wizSearch set counter=? set last=? where
ID=?") or die "blah blah blah";
$sth->execute ($searchCounter, $last_date, $chkfound);


OR


$sth = $dbh->prepare ("update wizSearch set counter=? last=? where
ID=?") or die "blah blah blah";
$sth->execute ($searchCounter, $last_date, $chkfound);

Which one?

-- 
He came from Econet - Oh no, I've run out of underpants :(
Home:- jaydee@wizdom.org.uk       http://www.wizdom.org.uk
Shadow:- webmaster@shadow.org.uk  http://www.shadow.org.uk
Work:- netman@hinwick.demon.co.uk http://www.hinwick.demon.co.uk
Web site Monitoring:-             http://www.shadow.org.uk/SiteSight/


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

Date: 1 Aug 2000 16:15:25 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: DBI:: UPDATE format (Perl DBI O'Reilly fails to explain properly)
Message-Id: <8m7eld$boc$1@provolone.cs.utexas.edu>

In article <juckMLAWuzh5EwiG@worsdall.demon.co.uk>,
Mark Worsdall  <linux@worsdall.demon.co.uk> wrote:
>In article <8m58gq$8u9$1@provolone.cs.utexas.edu>, Logan Shaw
><logan@cs.utexas.edu> writes
>>
>>       $sth = $dbh->prepare ("update wizSearch set counter=? where ID=?")
>>               or die "blah blah blah";
>>       $sth->execute ($searchCounter, $chkfound);
>>
>
>So if I was updating a 2nd field then it would be like this?

Have a look at the MySQL documentation for the update sql statement:

http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#UPDATE

Hope that helps.

  - Logan


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

Date: Tue, 1 Aug 2000 22:49:33 +0100
From: Mark Worsdall <linux@worsdall.demon.co.uk>
Subject: Re: DBI:: UPDATE format (Perl DBI O'Reilly fails to explain properly)
Message-Id: <dZybhUAtX0h5Ew3E@worsdall.demon.co.uk>

In article <8m7eld$boc$1@provolone.cs.utexas.edu>, Logan Shaw
<logan@cs.utexas.edu> writes
>In article <juckMLAWuzh5EwiG@worsdall.demon.co.uk>,
>Mark Worsdall  <linux@worsdall.demon.co.uk> wrote:
>>In article <8m58gq$8u9$1@provolone.cs.utexas.edu>, Logan Shaw
>><logan@cs.utexas.edu> writes
>>>
>>>       $sth = $dbh->prepare ("update wizSearch set counter=? where ID=?")
>>>               or die "blah blah blah";
>>>       $sth->execute ($searchCounter, $chkfound);
>>>
>>
>>So if I was updating a 2nd field then it would be like this?
>
>Have a look at the MySQL documentation for the update sql statement:
>
>http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#UPDATE
>
>Hope that helps.

It certainly does, I than you:-)

It is now working: http://www.wizdom.org.uk/cgi-bin/DisplaySearches.pl

-- 
He came from Econet - Oh no, I've run out of underpants :(
Home:- jaydee@wizdom.org.uk       http://www.wizdom.org.uk
Shadow:- webmaster@shadow.org.uk  http://www.shadow.org.uk
Work:- netman@hinwick.demon.co.uk http://www.hinwick.demon.co.uk
Web site Monitoring:-             http://www.shadow.org.uk/SiteSight/


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

Date: Tue, 01 Aug 2000 20:17:49 +0100
From: Tim Cockle <T.Cockle@staffs.ac.uk>
Subject: Detecting end of HTTP reply
Message-Id: <3987225D.53A384FF@staffs.ac.uk>

Hi,

I am writing a simple proxy.

But I don't seam to be able to detect the end of a HTTP reply.

All the examples I have looked at say to use:
while (<$server>)...
To continue to read until the end... But this does not seam to work!
All that happens is that the proxy continues to try and read until the
server kills the connection.

I am very new to this so I guess I am doing something silly here... Any
ideas?

Thanks in advance,

Tim



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

Date: Tue, 01 Aug 2000 20:20:15 GMT
From: "whitetigercat" <whitetigercat@home.com>
Subject: Re: downloading a file from a remote machine
Message-Id: <3iGh5.17282$Cm.583599@news1.gvcl1.bc.home.com>

Thank you, Mr. Keith.
Not only does all this work great, you've opened up a new world of all these modules for me.
(Ugh...more late nights!)
Thanks,
Shane

Colin Keith <ckeith@clara.net> wrote in message news:50Bh5.67$DT4.2184904@nnrp2.clara.net...
> In article <x6uh5.16649$Cm.573836@news1.gvcl1.bc.home.com>, "whitetigercat" <whitetigercat@home.com> wrote:
> >host has this module installed. I've written a lot of PERL code and never used
>
> At the cmd prompt:  perl -MLWP::Simple
> If it errors you don't have it installed (or its not in a place where perl
> could find it). If you can't get a prompt as a CGI script:
>
> #!/usr/bin/perl -w
> use strict;
>
> print "Content-Type: text/plain\n\n";
>
> eval { require  LWP::Simple; };
> if($@){
>   print "Ick something failed: $@\n";
> } else {
>   print "Found it and loaded it okay.\n";
> }
>
> Note that require is used instead of 'use' as use is acted on before
> runtime.
>
> >an external module before (ok, I probably did, but they were simple ones
> > like CGI::Carp qw(fatalsToBrowser); Can you or anyone give me a snippet of
> >code showing the actual downloading of a file from the web?
>
> Tut tut ;)
> But if you look at perldoc LWP::Simple you'll see all you need to straight
> off in the synopsis section:
>
>   use LWP::Simple;
>   $content = get("http://www.sn.no/")
>
> Try it. Add "print $content;" to the end of it and see what you get .. yup,
> $content is a copy of what the server returned for that query. Better
> still, look further down through the docs and you'll see:
>
>   getstore($url, $file)
>      Gets a document identified by a URL and stores it in
>       the file. The return value is the HTTP response code.
>
> You can plonk it on disk and process it from there..
>
>
>
> ---
> Colin Keith
> Systems Administrator
> Network Operations Team
> ClaraNET (UK) Ltd. NOC




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

Date: Tue, 01 Aug 2000 20:54:03 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: Dynamic String to hash
Message-Id: <39873866.E0AEB57B@netstorm.net>

Ken Hare wrote:
> 
> I know that I will need: Qty, SKU, Name, NoTax and Price with all of
> the other fields added in any order to the end of Name.
> 
> My strategy up to this point is to take the raw string and split it on
> the item delimiter and dump it into an array. Then take the array and
> somehow cram it into a hash using the first items "specs" (field names)
> as the keys and then supsequent item "specs" as columns. Then somehow
> iterate through this hash and build the new product string the way I
> want.
> 
> Is this the right strategy?

Sounds basically right to me.  The structure you choose depends on what
you want to do with all this information once you have assembled it, but
a hash of arrays may be what you need.  See
	perldoc perllol
for info on how to build your list and
	perldoc perlref
to understand what's going on in the list building process.

> I'd post my code but it is so messed up right now that it would simply
> confuse and not be useful in the end.

Clean it up as much as you can, test it, then post the part(s) (brief)
you're having trouble with.

-- Jim


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

Date: Tue, 01 Aug 2000 14:39:30 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: forking and child processes
Message-Id: <39874392.A9ECACC6@ipac.caltech.edu>

matt venn wrote:
> 
> 1) how do i make sure that if my parent process is killed, it takes
> its children with it? would i assign a relevant handler to SIG{} to
> kill the children?

That's a good option to explore. You can't use 'END' blocks because they
won't execute if the parent dies due to a signal unless it's itrapped.

> ive read the man pages on kill, and it doesnt seem to kill any child
> processes, so in the normal case do the children just get handed over
> to init?

Where does it say children are not killed? I've used it thus many times.
You just need the child's PID, as returned from the fork.

> 2) i have noticed that if my parent is sleeping, and a child dies
> (assuming i have set up a 'reaper' sub); the sleep is interrupted, and
> when normal execution resumes, the sleep is not finished. how could i
> overcome this? is this actually not a problem in reality because its
> unlikely for the parent to need to sleep for a specific amount of
> time?

Something like

$needed_sleep = 100;
$t0 = time;
SLEEP: {
  sleep $needed_sleep;
  $needed_sleep -= time - $t0;
  redo SLEEP if $needed_sleep > 0;
}

or read the perlfunc write-up on 'alarm' and see if you can make
something of that.

--

-- Tim Conrow         tim@ipac.caltech.edu       626-395-8435


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

Date: Tue, 01 Aug 2000 21:46:45 GMT
From: matt@NOSPAMcipherdesign.com (matt venn)
Subject: Re: forking and child processes
Message-Id: <398744dd.45944304@news.ntlworld.com>

thanks for the help,
and to clarify, i was talking about bash's kill function, which only
seems to kill the parent process and not the children.

i think i have some more questions regarding this, but im not sure if
they are real questions or something that i can solve myself.  some
more playing will find out ;)

thanks again,
matt


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

Date: Tue, 01 Aug 2000 16:58:38 -0500
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: forking and child processes
Message-Id: <3987480E.1724A432@arnis-bsl.com>

matt venn wrote:
> 
> thanks for the help,
> and to clarify, i was talking about bash's kill function, which only
> seems to kill the parent process and not the children.
> 
> i think i have some more questions regarding this, but im not sure if
> they are real questions or something that i can solve myself.  some
> more playing will find out ;)
> 

IMHO the right place to learn more about things like kill(), fork(),
wait()
and other system calls is your OS's man pages and OS-related FAQs/books.

Perl's kill() function and an external kill command - all are just
wrappers for a kill system call (and for other calls as well).

Ilja.


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

Date: Tue, 01 Aug 2000 22:23:34 +0200
From: Matthias Oswald <mabios@t-online.de>
Subject: How to show "tail -f" in browser
Message-Id: <398731C6.BB6AECD0@t-online.de>

Hi,

I am developing a user inferface based on a HTML page and the processing

behind in perl/ksh script.

Is there a convenient way to show the log of the processing in the
browser ?
I was thinking of doing a tail -f on the process log file and show it
somehow in another frame of the browser.
Maybe someone has an example?

Your help is much appreciated.

Thanks,
Matthias Oswald
email: moswald@husky.ca, mabios@t-online.de



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

Date: Tue, 01 Aug 2000 14:18:07 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: How to show "tail -f" in browser
Message-Id: <39873E8F.7F7D66A7@ipac.caltech.edu>

Matthias Oswald wrote:
> I was thinking of doing a tail -f on the process log file and show it
> somehow in another frame of the browser.
> Maybe someone has an example?
> email: moswald@husky.ca, mabios@t-online.de


From perlfaq5
  
   How do I do a `tail -f' in perl?

 ... key snippet:

         for (;;) {
           for ($curpos = tell(GWFILE); <GWFILE>; $curpos =
tell(GWFILE)) {
             # search for some stuff and put it into files
           }
           # sleep for a while
           seek(GWFILE, $curpos, 0);  # seek to where we had been
         }

[Removed the modules list from my reply.]

--

-- Tim Conrow         tim@ipac.caltech.edu       626-395-8435


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

Date: Tue, 01 Aug 2000 20:35:04 GMT
From: slandman@my-deja.com
Subject: htaccess and cgi script
Message-Id: <8m7c9n$dnu$1@nnrp1.deja.com>

I'm going to switch a site from a NT server to a UNIX server if you
folks answer my question.  I need to password protect some pages of a
cgi script.  I haven't used .htaccess before, but I assume that I will
be able to do this with .htaccess.  Am I correct?

Thanks.

Steve


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


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

Date: 01 Aug 2000 14:12:29 -0700
From: Matthew Emmett <memmett@fraser.sfu.ca>
Subject: Re: htaccess and cgi script
Message-Id: <yvw9lmyg3cua.fsf@fraser.sfu.ca>

slandman@my-deja.com writes:

> I need to password protect some pages of a cgi script.

Hmmm, ya lost me.  If you'd like to password protect html files or cgi
scripts that reside in a certain directory, then yes, you can use
 .htaccess.


> I haven't used .htaccess before, but I assume that I will be able to
> do this with .htaccess.  Am I correct?

Yes, correct.  Just make sure to tweak the config files in the
appropriate ways.  I won't elaborate, because we're way off topic
(this is a perl newsgroup :)

Matt



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

Date: Tue, 01 Aug 2000 13:26:30 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: I have an idea but will it work ?
Message-Id: <39871656.1B7ED0C@home.com>

Phil Latio wrote:
> 
> I would now like to display the price of the printing job dynamically.
> 
> Could I create a 5 field flat file database something like below 
> with a line per record and then have a perl script that would search
> the database on the first 4 fields from the values entered by the
> customer (look up feature?) and drop in the price automatically.
> 
> COLOUR,WEIGHT,SIDED,QUANTITY,PRICE
> white, 80gsm, s/sided, 1000, £40.00
> white, 80gsm, s/sided, 2500, £75.00
> etc
> etc
 
Sure, but I wouldn't do it by searching the file -- that would get messy
and tend to obfuscate the logic. I'd read the file into a hash, and then
do your lookups that way.

#!/usr/local/bin/perl -w
use strict;

my %print_cost;

while (<DATA>) {
    chomp;
    my ($color, $weight, $sided, $quantity, $price) = split;
    $print_cost{$color}{$weight}{$sided}{$quantity} = $price;
}

# This data would come from your form
my $number = 1000;
my $weight = '80gsm';
my $sides  = 's/sided';
my $color  = 'white';

# And spit out the price
printf("The price for %d %s, %s, %s prints is %s.\n",
    $number, $color, $weight, $sides,
    $print_cost{$color}{$weight}{$sides}{$number});

__DATA__
white 80gsm s/sided 1000 £40.00
white 80gsm s/sided 2500 £75.00

You'll want to consider other things, like what if the user wants 1004
copies? (if that's an option). Also, if the number of possible
combinations is truly large, creating that file would be a pain. (Are
1000 copies on blue paper going to cost something different than they do
on green paper? What happens when supply costs go up and you need to
change every entry to compensate?)

Perhaps some sort of formula would be better? e.g. 80gsm paper costs 5
pence/copy, color is 1 pence/copy extra, double-sided copies cost 1.3
times single-sided, 2500+ copies get a 15% discount, etc... You probably
already have a formula like this that you use to come up with your
pricing. Why not use it directly?

-mjc


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

Date: Tue, 01 Aug 2000 15:14:01 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: I have an idea but will it work ?
Message-Id: <39872179.7CBA6570@attglobal.net>

Michael Carman wrote:
> 
> 
> Sure, but I wouldn't do it by searching the file -- that would get messy
> and tend to obfuscate the logic. I'd read the file into a hash, and then
> do your lookups that way.
> 

What if the OP has too much data to read into the hash?  
I see a better option as a tied hash, but even better is 
using a DBI module to search against the file via SQL queries.

If the combinations can get very complicated, perhaps a real
database is in order.


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

Date: 01 Aug 2000 15:46:09 -0400
From: dc@panix.com (David W. Crawford)
Subject: Re: INfo on the environment variables
Message-Id: <xz3wvi0wyri.fsf@panix6.panix.com>

tadmc@metronet.com (Tad McClellan) writes:

> On Mon, 24 Jul 2000 18:20:35 -0500, Murari Gopalan <mgopalan@students.uiuc.edu> wrote:
> 
> >I need more info on %ENV. more specifically i need info on the varius env
> >variables accessible through this hash... 

As noted elsewhere on this thread, you can enumerate your ENV
variables and their values:

print ($_,$ENV{$_}) foreach (keys %ENV);  
 
> Then you do not need info on Perl's %ENV hash, you need info
> on the environment of whatever Operating System you happen
> to be using.
> 
> Perl just passes through whatever your OS uses.

Yes, and you're running perl in an Apache context, then you
get an ENV of Apache variables.

http://omor.com/perl/env.cgi

David W. Crawford    <dc@panix.com>
Los Gatos, CA  




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

Date: Tue, 01 Aug 2000 23:10:23 +0200
From: "haggi@work" <haggi@tappe.net>
Subject: killing process 1
Message-Id: <39873CBF.7959291E@tappe.net>


This below is the programm I try to make.
But the program called "render" never dies. 
I dont know why. 

I use  perl 5.005 for cygwin on winNT.

Is this an NT problem, or a perl problem or am I too stupid
to kill the process?

The program exits, and I get a prompt in the shell.
But the taskmanager says there is still a perl process and the
renderer running. 

If i hit CTRL-C all is terminated.

Please help.

haggi 


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

#!/usr/local/bin/perl

 
    if ($pid = fork){
 
       sleep(5); 	       
       kill KILL, $pid;
       sleep(5);
       exit;
       
    }elsif (defined $pid){

      print("Childprocess started\n");
      
      $rcmd="render -s 90  -e 106  -b 1 rsTest.ma";
      
      open (RENDER,"$rcmd|");
      while(<RENDER>){
        print;
      }
      exit;
    }	


 

-- 

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

	haggi
	www.haggi.de
	haggi@haggi.de

	haggi`s visual effects & animation

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


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

Date: Tue, 01 Aug 2000 22:22:49 +0200
From: "haggi@work" <haggi@tappe.net>
Subject: killing process
Message-Id: <39873199.2AEE9C5A@tappe.net>


Hi,

I try to kill a process with perl command kill.

I start a childprocess which starts a rendering program, while the
parent process is waiting for new commands. 

The rendering programm is started with a pipe:

 

   open (RENDER, $rcmd| )

no problem the renderincommand starts. But if I kill the childprocess,
the rendering programm is still running. 

any help?


-- 

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

	haggi
	www.haggi.de
	haggi@haggi.de

	haggi`s visual effects & animation

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


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

Date: Tue, 01 Aug 2000 15:56:03 -0500
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: killing process
Message-Id: <39873962.BBE9E20A@arnis-bsl.com>

haggi@work wrote:
> 
> Hi,
> 
> I try to kill a process with perl command kill.
> 
> I start a childprocess which starts a rendering program, while the
> parent process is waiting for new commands.
> 
> The rendering programm is started with a pipe:
> 
> 
> 
>    open (RENDER, $rcmd| )
> 
> no problem the renderincommand starts. But if I kill the childprocess,
> the rendering programm is still running.
> 

If I understand right, you kill() the child process,
but the parent remains running. 
This behavior is OK (and was discussed today in some 
other thread here).

BTW, you may install a signal handler for the parent process
(via $SIG{CHLD}) to catch the child's death and terminate himself.

Hope this help.
Ilja.


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

Date: Tue, 01 Aug 2000 23:13:21 +0200
From: "haggi@work" <haggi@tappe.net>
Subject: Re: killing process
Message-Id: <39873D71.305CF31C@tappe.net>


I tried this with several signals. I can catch the
signal and try to exit, but there is still my render process which I started with
"open" running in the background.

maybe it is WindowsNT.

haggi


Ilja Tabachnik wrote:
> 
> haggi@work wrote:
> >
> > Hi,
> >
> > I try to kill a process with perl command kill.
> >
> > I start a childprocess which starts a rendering program, while the
> > parent process is waiting for new commands.
> >
> > The rendering programm is started with a pipe:
> >
> >
> >
> >    open (RENDER, $rcmd| )
> >
> > no problem the renderincommand starts. But if I kill the childprocess,
> > the rendering programm is still running.
> >
> 
> If I understand right, you kill() the child process,
> but the parent remains running.
> This behavior is OK (and was discussed today in some
> other thread here).
> 
> BTW, you may install a signal handler for the parent process
> (via $SIG{CHLD}) to catch the child's death and terminate himself.
> 
> Hope this help.
> Ilja.

-- 

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

	haggi
	www.haggi.de
	haggi@haggi.de

	haggi`s visual effects & animation

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


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

Date: Tue, 01 Aug 2000 19:18:02 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: Newbie question: # of characters in a string
Message-Id: <39871f68.21793156@news.earthlink.net>

On Mon, 31 Jul 2000 23:36:01 -0500, "Dietmar Staab"
<dietmar.staab@t-online.de> wrote:

>In article <3985e6e0.25438893@news.earthlink.net>,
>jonceramic@nospammiesno.earthlink.net (Jon S.) wrote:
>> I can't seem to count the number of characters in a string.  I've tried
>Try function "length".
>
>BTW, don't try length to find the size of an array or hash
>
>Use "scalar @array" resp. scalar keys %hash for these data structures.
>
>Look at the documentation, Luke. ;-)

Thanks D (and Greg)...

Length solved it on the first pass.  I think I searched for just about
every word that length would generate in a thesaurus.  "Count",
"size", "number of", etc...  

I should have just closed my eyes and let the function come to me.

Jon


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

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


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