[16067] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3479 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 26 06:05:26 2000

Date: Mon, 26 Jun 2000 03:05:12 -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: <962013911-v9-i3479@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 26 Jun 2000     Volume: 9 Number: 3479

Today's topics:
    Re: "Kill" function doesn't work. (Bart Lateur)
    Re: 500 Internal Server Error? <bill.kemp@wire2.com>
    Re: attach file in e-mail (David Efflandt)
    Re: defined() (Bart Lateur)
    Re: defined() <sumus@aut.dk>
    Re: Error checking with Getopts (Johan Vromans)
        Golf (Was: Re: HELP ME PLEASE !!!!) <sumus@aut.dk>
        HLP: SDBM_File problem concering element length <craiger316@visi.com>
        How is a unique sort done? Like unix "sort -u" <robert@chalmers.com.au>
    Re: How is a unique sort done? Like unix "sort -u" <sumus@aut.dk>
    Re: How is a unique sort done? Like unix "sort -u" <mdemello@pound.ruf.rice.edu>
        howto use the package "Filter::*" ? <udo.kuehne@inatec.com>
        indentifying country origin using perl?? <janneNOjaSPAM@funplanet.com.invalid>
    Re: Know of any good perl books? (David H. Adler)
    Re: Know of any good perl books? <miles@explorer.demon.co.uk>
    Re: move from Unix to NT - - MSQL to Perl scripts broke <Peter.Dintelmann@dresdner-bank.com>
    Re: move from Unix to NT - - MSQL to Perl scripts broke (Bart Lateur)
    Re: NT vs Unix detection <Petri_member@newsguy.com>
    Re: on again/off again CGI prob... (Bart Lateur)
        Online En-/Decryption Module (Wolfgang Engels)
    Re: OpenFile then Chomp <gellyfish@gellyfish.com>
        RE: perl4 out of memory on HPUX (H. Merijn Brand)
    Re: Reg Expression Question tony_123@my-deja.com
    Re: Running Perl CGI Scripts <miles@explorer.demon.co.uk>
    Re: system and exec 'holds' perl output omtslug@my-deja.com
    Re: uncoupling SQL from object classes (jason)
    Re: User's details (David Efflandt)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 26 Jun 2000 09:10:23 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: "Kill" function doesn't work.
Message-Id: <395d1ddc.6444569@news.skynet.be>

Weiguang Shi wrote:

>I wrote the one-line script to kill all the processes with 4404<pid<4900
>below:
>
>$ ps -u wgshi|perl -ne 'chop(); @a=split / /;if($a[1]<4900 && $a[1]>4404)
>  {kill 9, $a[1], "\n";} '
>Killed
>
>And got the answer "Killed" as shown above. However, none of the processes
>was actually killed. Why this happened?

Permission?

-- 
	Bart.


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

Date: Mon, 26 Jun 2000 10:02:24 +0100
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: 500 Internal Server Error?
Message-Id: <962010268.8729.0.nnrp-11.c3ad6973@news.demon.co.uk>

<snip>
Sorry , but the above error doesn't help.
Any error in the cgi script will give the above.
If there are no valid headers it will give 500, and if the script stops for
any reason before this (such as syntax errors), there are no headers.





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

Date: 26 Jun 2000 07:44:00 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: attach file in e-mail
Message-Id: <slrn8le2de.p29.efflandt@efflandt.xnet.com>

On Mon, 26 Jun 2000 10:02:42 +0800, JL <ltlau@yahoo.com> wrote:
>Hi,
>Can anyone tell me how to use perl to attach file like using e-mail in
>yahoo/hotmail?
>Thanks alot.

If you are talking about from CGI, the CGI module and MIME::Lite work well
to generate a form with file upload and process the form for e-mailing the
uploaded file(s).  If you are talking about a standalone script I guess
you could use MIME::Lite along with Mail::Sendmail if you don't have your
own smtp server (or Blat in Windows).

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Mon, 26 Jun 2000 09:02:34 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: defined()
Message-Id: <39570866.950477@news.skynet.be>

Jakob Schmidt wrote:

>Now this whole thing got me curious so I went and tested it. And it appears
>that the while test is smarter than we dared to assume: Apparantly it
>tests for definedness (as opposed to trueness) when the predicate involves
>the <HANDLE> operator:

This whole discussion is (partly?) obsolete. From 5.005 on, the magic
while(<HANDLE>) thing has been changed to mean

	while(defined($_ = <HANDLE>) ) { ... }

The "defined" test is built-in. If you want to see the flaw in action,
use an older perl.

BUT: I'm not sure if this magic works if you explicitely assign to a
variable. Test it again with:

	while($_ = <DATA>) { ... }

It still won't fail on this system (5.005_02)...

-- 
	Bart.


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

Date: 26 Jun 2000 11:56:37 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: defined()
Message-Id: <pup4zrxm.fsf@macforce.sumus.dk>

bart.lateur@skynet.be (Bart Lateur) writes:

> The "defined" test is built-in. [...]

That's what I found out :-)

> BUT: I'm not sure if this magic works if you explicitely assign to a
> variable. Test it again with:
> 
> 	while($_ = <DATA>) { ... }

No offense, but if you re-read my former post you'll find that I did test
that - and it works allright on my system as well. Perl is smart :-)

-- 
Jakob


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

Date: 26 Jun 2000 09:05:16 +0200
From: JVromans@Squirrel.nl (Johan Vromans)
Subject: Re: Error checking with Getopts
Message-Id: <wl3hfag2a8j.fsf@plume.nl.compuware.com>

pmacadam@my-deja.com writes:

> Thank you. Very helpful.
> I looked briefly at Getopt::Long and thought it was only for full-word
> switches.

Well, a one-character switch is just a very short word ;-).

If you want to use bundling (common with one-letter options), e.g. 
"-xyp parg" meaning "-x -y -p arg", you need to call

  Getopt::Long::Configure("bundling");

before caaling GetOptions.

-- Johan


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

Date: 26 Jun 2000 10:53:36 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Golf (Was: Re: HELP ME PLEASE !!!!)
Message-Id: <8zvs257z.fsf_-_@macforce.sumus.dk>

Jakob Schmidt <sumus@aut.dk> writes:

> "Lee Millard" <lee.millard@ntlworld.com> writes:
> 
> > How do I get my script to display a list of directories that are in the
> >same directory as the script ???
> 
> opendir DIR, '.';
[oops - should have tested for success here I guess]
> while ( $_ = readdir DIR ) { -d $_ and print $_, "\n" }

Oh man - I suddenly discovered that this was actually an invitation to golf.

Wonder how this will do:

opendir D, '.'; print join $/, grep -d, readdir D;


There are a number of variants of which I'll mention a few:

# if you think it really ought to be a single statement:
opendir D, '.' and print join $/, grep -d, readdir D;

# if you think it should be nicer:
opendir D, '.' or die $!; print join $/, grep -d, readdir D;

# if you hate output that ends without a \n:
opendir D, '.'; print join $/, grep( -d, readdir D ), '';

# if you think it's too dirty to save two chars by relying on the default $/:
opendir D, '.'; print join "\n", grep -d, readdir D;

- most these moderations can be combined - but I think the original one
captures the golf spirit the best.


NB: I use a lot of whitespace. Redundant whitespace does not count as
strokes.

-- 
Jakob


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

Date: Mon, 26 Jun 2000 03:34:11 -0500
From: "Craig Tataryn" <craiger316@visi.com>
Subject: HLP: SDBM_File problem concering element length
Message-Id: <htE55.1697$iN5.339868@ptah.visi.com>

Hi, I have a piece of code which does the following:

<CODE>
sub SetSessValues {
 # Store values for a given session id
 # Takes an associative array as argument, saves to session file

 require SDBM_File;
 require Fcntl;
    my ($Sessionid, $Where, %DBMdb) = @_;
    my %tiedDB;
    my $key;
    my %Global = Utils::GetGlobalSettings();

    # Open the session file and set values:
    tie(%tiedDB, 'SDBM_File',
"$Global{DirectorySession}/$Sessionid-$Where.DB",
Fcntl::O_RDWR()|Fcntl::O_CREAT(), 0644) ||
   HTMLError("Unable to open session file for sessionid -", $Sessionid, "-
for writing ($!).");

    # Set the values in the DB to values passed as argument:
    %tiedDB = %DBMdb;

    # Store the new values:
    untie(%tiedDB);
}

</CODE>

On the line where I set %tiedDB = %DBMdb my script dies.  It only dies when
an element in the DBMdb hash is rather long (let's say 200+ characters
although I don't know the actual size that causes it to crash).  I was
wondering if anyone knows if there is a limit to the size of hash elements
being saved using this method, and if there is, is there a work around?

Any help would be greatly appreciated!

Thanks,

Craig.

--
Craig W. Tataryn
Senior Staff Analyst (BSc.Cs., MCP)
Compuware Professional Services
Bloomington, MN




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

Date: Mon, 26 Jun 2000 18:49:03 +1000
From: "Robert Chalmers" <robert@chalmers.com.au>
Subject: How is a unique sort done? Like unix "sort -u"
Message-Id: <gME55.2$i3.262@nsw.nnrp.telstra.net>

How do I make a sort do a unique sort ??? this is a real mystery...

This is standard sort...
@result = sort { $a cmp $b } @newdom;
   for ($x=0; $x < $array; $x++) {
    print  $result[$x];
  }


where the rows might contain

aaaaaaa.aaaaaaa
aaaaaaa.aaaaaaa
bbbbbbb.bbbbbbb
bbbbbbb.bbbbbbb
and thats what it returns...

but how do you program it so it only returns into the array,
aaaaaaa.aaaaaaa
bbbbbbb.bbbbbbb

Can't see a way to do this anywhere???/

Any ideas anyone?
Thanks
Bob




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

Date: 26 Jun 2000 11:48:04 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: How is a unique sort done? Like unix "sort -u"
Message-Id: <r99kzsbv.fsf@macforce.sumus.dk>

"Robert Chalmers" <robert@chalmers.com.au> writes:

> How do I make a sort do a unique sort ??? this is a real mystery...

The kernel of the problem is how to get an array of uniques. When you've got
that simply sort it.

This is a FAQ item:

perldoc -q unique

- but actually I think I have a better answer than (my local version of) the
FAQ for this case:

my %h;               # this is just to make sure %h is not already in use
@h{ @newdom } = ();  # this assigns undef to each value in the hash %h
                     # now use keys( %h ) as source for your sort

> This is standard sort...
> @result = sort { $a cmp $b } @newdom;
>    for ($x=0; $x < $array; $x++) {
>     print  $result[$x];
>   }

Oh, and don't use the C style for loop. Perl has much more powerful tools.
In the above you have to first assign the number of elements to $array
and after uniqueifying the array you don't actually know that. Of course
you can find it out - but why not do it the Perl way? Oh, and
sort { $a cmp $b }, @xxx does the same as simply sort @xxx so if you don't
want anything special going on while sorting:

@result = sort keys %h;
for ( @result ) { print }

Now here's a quick and dirty little thing which you could use if you just
wan to print the sorted unique list provided that you're not using %h
elsewhere:

@h{ @newdom } = ();
for ( sort keys %h ) { print }

Now here's an even niftyer - and actually a little cleaner - way to do
the same thing (but I admit that it's beginning to get hard to read to
the unperly eye):

for ( sort do { my %h; @h{ @newdom } = (); keys %h } ) { print }

Or if what you really want is the list itself:

@result = sort do { my %h; @h{ @newdom } = (); keys %h };

Or maybe you want a subroutine?:

sub uniqueSort
{
  sort do { my %h; @h{ @_ } = (); keys %h };
}

Then you can go

@result = &uniqueSort( @newdom );  # the '&' can be omitted when you use ()

etc.

-- 
Jakob


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

Date: 26 Jun 2000 09:42:36 GMT
From: Martin Julian DeMello <mdemello@pound.ruf.rice.edu>
Subject: Re: How is a unique sort done? Like unix "sort -u"
Message-Id: <8j78ic$kcj$1@joe.rice.edu>

Robert Chalmers <robert@chalmers.com.au> wrote:
> How do I make a sort do a unique sort ??? this is a real mystery...

perldoc -q unique

-- 
Martin DeMello


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

Date: Mon, 26 Jun 2000 09:58:46 +0200
From: "udoline" <udo.kuehne@inatec.com>
Subject: howto use the package "Filter::*" ?
Message-Id: <8j72hc$66120$1@fu-berlin.de>

Hi,


howto use the package "Filter::*" ?

how make I the perlsource encrypted ?

Is the security from encrypted perlsource ?


ThankX for any hints

udoline






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

Date: Mon, 26 Jun 2000 01:25:14 -0700
From: dagolfmasta <janneNOjaSPAM@funplanet.com.invalid>
Subject: indentifying country origin using perl??
Message-Id: <0146ce5a.6fe64e71@usw-ex0108-062.remarq.com>

Is it possible to determine the origin of somebody browsing
my pages?
How can I access the IP-adress of the html-page that is
calling my scripts? Through the IP-adress I could determine
country origin because I have different sites for different
countries.

Thanks in advance

/Janne


* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is Beautiful


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

Date: 26 Jun 2000 08:27:04 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: Know of any good perl books?
Message-Id: <slrn8le4uo.re7.dha@panix6.panix.com>

On Thu, 22 Jun 2000 13:44:17 -0400, Drew Simonis
<care227@attglobal.net> wrote:

>mark_f_edwards@my-deja.com wrote:
>> 
>> i hear 'effective perl programming' is pretty good, too.
>> any book written by RANDAL SCHWARTZ is very educational and useful.
>
>Thanks to the powers that be that Mr. Schwartz is not as picky as
>a certain monospaced font/no mixed case/no punctuation after the d
>personage known to pass by this way =)

The d is also silent...

><duck>

 ...aiming low to compensate.  :_)

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Que?" - Manuel


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

Date: Mon, 26 Jun 2000 10:43:21 +0100
From: "Miles Davenport" <miles@explorer.demon.co.uk>
Subject: Re: Know of any good perl books?
Message-Id: <962012467.28100.0.nnrp-09.d4e4dc01@news.demon.co.uk>

Try http://perl.oreilly.com/

Oreilly have a great selection of Perl books.

Perl 5 Pocket Reference, 3rd Edition

These are the ones I have, and use most.

cheers

Miles.



Programming Perl, 2nd Edition

David H. Adler <dha@panix.com> wrote in message
news:slrn8le4uo.re7.dha@panix6.panix.com...
> On Thu, 22 Jun 2000 13:44:17 -0400, Drew Simonis
> <care227@attglobal.net> wrote:
>
> >mark_f_edwards@my-deja.com wrote:
> >>
> >> i hear 'effective perl programming' is pretty good, too.
> >> any book written by RANDAL SCHWARTZ is very educational and useful.
> >
> >Thanks to the powers that be that Mr. Schwartz is not as picky as
> >a certain monospaced font/no mixed case/no punctuation after the d
> >personage known to pass by this way =)
>
> The d is also silent...
>
> ><duck>
>
> ...aiming low to compensate.  :_)
>
> dha
>
> --
> David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
> "Que?" - Manuel




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

Date: Mon, 26 Jun 2000 09:12:05 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: move from Unix to NT - - MSQL to Perl scripts broken
Message-Id: <8j6vnv$7nk1@intranews.dresdnerbank.de>

    Hi,

cheena88@my-deja.com schrieb in Nachricht <8j0oro$oci$1@nnrp1.deja.com>...
> Now that we are on an NT, our scripts will not run,
>obviously.

    so next time you will develop them with a
    possible change of the platform in mind ;-)

>  I am trying to find out if MSQL 2.0 is available on an NT

    have a look at http://www.mysql.org

>and if Perl is already installed, is there an API library for the NT
>server?

    Perl is of course available on NT. Have a look at
    http://www.activestate.com You will find all modules
    you need in http://www.activestate.com/packages/zips

    Best regards,

        Peter Dintelmann






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

Date: Mon, 26 Jun 2000 09:02:37 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: move from Unix to NT - - MSQL to Perl scripts broken
Message-Id: <39580a6f.1471056@news.skynet.be>

Dr. Peter Dintelmann wrote:

>>and if Perl is already installed, is there an API library for the NT
>>server?
>
>    Perl is of course available on NT. Have a look at
>    http://www.activestate.com You will find all modules
>    you need in http://www.activestate.com/packages/zips

Note that, for the moment, there are still more modules available for
5.005 than for 5.6. These versions are not binary compatible, so if your
module uses it's own DLL, you may have to temporarily use a slightly
older Perl.

-- 
	Bart.


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

Date: 26 Jun 2000 01:56:18 -0700
From: Petri Oksanen <Petri_member@newsguy.com>
Subject: Re: NT vs Unix detection
Message-Id: <8j75ri$1ivp@edrn.newsguy.com>

In article <VA.0000003c.258d71ee@cwia.com>, Larry says...
> For now I'm just depending on an environment variable 
> that's in NT that's not in Unix.

Look at how pl2bat checks if users are running Win9x or WinNT.
If you absolutely must use environment variables then that would be a solution.

if "%OS%" == "Windows_NT" goto WinNT


Petri Oksanen



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

Date: Mon, 26 Jun 2000 09:02:43 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: on again/off again CGI prob...
Message-Id: <395a15e3.4403282@news.skynet.be>

Ryan Stewart wrote:

>Error Message       : fatal error: Can't locate strict.pm in @INC (@INC
>contains: D:\Websites\Paintball.Org\cgi-bin\links .) at

Now that is not enough.

>d:/Websites/Paintball.Org/cgi-bin/Links/admin/Template.pm line 21.


So @INC contains only a small number of paths, related to the 
directory of the script. Where is "lib"? Where is "site"? 
Now, *that* is your problem.

I can only assume that you're on NT, and using ActiveState's perl. I've
recently read in this newsgroup that this perl very probably
(experiments point in that direction) looks up the directory of the
executable, and builds "lib" and "site/lib" paths from it, and put them
into @INC before any script runs. For some reason, this occasionaly
fails at your ISP. Either there is a bug in ActiveState, or the server
is slightly unstable at the time when this happens, so that the
directory lookup occasionally fails. I'd tend to think it's the latter.

Now, what can YOU do? Look up the paths in @INC when the scripts do work
properly, and put them into @INC yourself. Unfortunately, you can't use
"use lib", because in case of failure, "lib.pm" itself won't be found
either. This ought to work at all times:

	BEGIN {
	    push @INC, 'path/to/lib', 'path/to/site/lib', ...;
	}

Of course, you must replace these fake paths with what you found.

-- 
	Bart.


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

Date: Mon, 26 Jun 2000 08:38:35 GMT
From: wolfgang.engels@arxes.de (Wolfgang Engels)
Subject: Online En-/Decryption Module
Message-Id: <39571668.7689546@news.ginko.de>

Hi!

I'm looking for a way encrypt my perlsource and decrypt it on runtime.
Intershop 4 uses such an encryption which is called NetCrypt.
Is there anything out there which can do it. or is there any other
suggestion how to secure a perlscript on the web that contains
information about accessing databases?

Thanx,
Wolfgang Engels

arXes Information Design AG
Aachen, Germany


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

Date: 26 Jun 2000 10:19:04 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: OpenFile then Chomp
Message-Id: <8j7768$puf$1@orpheus.gellyfish.com>

On Sun, 25 Jun 2000 08:36:06 -0400 Bernie Cosell wrote:
> Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> 
> } > Well, opening and closing files a lot is a pretty slow operation, I'd think
> } > [the read and chomp is probably not bad].  One alternative would be to let
> } > Unix do the work for you.  If the set of files is known, I'd bet that the
> } > fastest way to do it would be to do:
> } > 
> } >     open (FIRST, "head -1 <LOTS OF FILES> | ")
> } > 
> } 
> } Of course it might make a difference how many file 'LOTS OF FILES' is ...
> 
> Probably not --- I suspect it'll always be faster than almost anything you
> can do short of XSUB'ing it in C.  If the # of files is HUGE, you can
> always open:
>       "find <files> [appropriateconditions] | xargs head -1 |"
> or whatever works to get at all the filenames and use xargs to keep the
> command lines under control.
> 

Thats what I meant.

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: Mon, 26 Jun 00 11:12:21 +0200
From: h.m.brand@hccnet.nl (H. Merijn Brand)
Subject: RE: perl4 out of memory on HPUX
Message-Id: <8F5F78D06Merijn@192.0.1.90>

alex.graf@ec.gc.ca (Alex Graf) wrote in <3953c58b.73088325@morgoth.sfu.ca>:

>HP-UX 10.20

perl 5.6.0

-- 
H.Merijn Brand
using perl5.005.03 and 5.6.0 on HP-UX 10.20, HP-UX 11.00, AIX 4.2, AIX 4.3,
  DEC OSF/1 4.0 and WinNT 4.0 SP-6a,  often with Tk800.022 and/or DBD-Unify
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/H/HM/HMBRAND/
Member of Amsterdam Perl Mongers (http://www.amsterdam.pm.org/)


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

Date: Mon, 26 Jun 2000 07:58:09 GMT
From: tony_123@my-deja.com
Subject: Re: Reg Expression Question
Message-Id: <8j72ec$sn8$1@nnrp1.deja.com>

Thanks for all the help on this problem.  I have put the suggestions to
work ! :)

Cheers

Tony

In article <8imldk$f61$1@nnrp1.deja.com>,
  tony_123@my-deja.com wrote:
> Hi Folks
>
> I have the string
>
> $MyString='<img src="http://www.myhouse.com.au/house.gif">';
>
> Can someone please tell me how I can extract the house.gif part of
this
> string.
>
> Cheers
>
> Tony
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


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


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

Date: Mon, 26 Jun 2000 10:31:22 +0100
From: "Miles Davenport" <miles@explorer.demon.co.uk>
Subject: Re: Running Perl CGI Scripts
Message-Id: <962011745.27834.0.nnrp-09.d4e4dc01@news.demon.co.uk>

I thought ps -ef ran on most versions of Linux/Unix.  If not, then
/usr/ucb/ps -aux should be ok with most flavours.

Yes doing a chmod a+wrx would cause a security hole :)





mike <mikes@escape.com> wrote in message
news:3954BF3E.485CDB9C@escape.com...
>
>
> Miles Davenport wrote:
>
> > Check your process table, and see what apache is running as:
>
> Hi Mike,
>                 what is the purpose of checking my process tables
> to see what apache is running as? I'm not sure what that means.
> What will I get out of the process table to be able to help with
> running the Perl scripts?
>                                                   Thanks
>                                                         Mike
>




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

Date: Mon, 26 Jun 2000 08:36:27 GMT
From: omtslug@my-deja.com
Subject: Re: system and exec 'holds' perl output
Message-Id: <8j74ma$u5m$1@nnrp1.deja.com>

Hi & Thanks.
closing stdout and stderr did it.
making stdout unbuffered did not fix this but now I'm on track again :-)
//Stefan

In article <m07lbjdn7k.fsf@alstadhome.cyberglobe.net>,
  Hakon Alstadheim <hakon.alstadheim@oslo.mail.telia.com> wrote:
> I wrote:
> > Ok, here is how you might reaon about this problem:
> [lots of ho-hum]
> > close(STDIN);close(STDERR);close(STDOUT);
> [more ho-hum]
> > b) If it does not, look up the functions 'fork' and exec. If you
need
> > this, you most certainly will have to use it in conjunction with a).
> This was written too early in the morning. I should have known
> better. I've been dreading Tom Phoenix' wrath all day. (By the way,
> when I'm awake I'm totally behind most of what Tom Poenix says).
>
> My (previously posted) solutions will most certainly get the output
> through the web-server, but I 'forgot' the reason _why_ you don't see
> any output until your app finishes:
>
> When -t STDOUT returns false (see perldoc -f -X) STDOUT will be
> buffered. A more elegant way would be to flush STDOUT (see perldoc
> IO::Handle), or make STDOUT unbuffered (same doc). That way you could
> send what you have in the output-buffer before running the lengthy
> command, but still get output from that command directed to the same
> stream (``i.e. sent to the browser'').
>
>


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


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

Date: Mon, 26 Jun 2000 07:56:22 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: uncoupling SQL from object classes
Message-Id: <MPG.13c1a9df3d80b892989750@news>

Brian .. to begin with - please don't just add your reply to the top of 
a post .. it's bad usenet etiquette - intersperse your reply with the 
original post - or cut it out altogether

bsmith@webnetint.com writes ..
>I think I understand what you are doing, though due to my inexperience
>with OO terms, I'm not sure how to apply this to me situation.  For
>example, I have a Person class with attributes like person_id,lastname,
>firstname, ssn, etc.
>
>I want a "save" method that 1. inserts data into db if the person
>doesn't exists (the person_id attribute doesn't exist) or 2. updates
>the data if the person_id exists.

the idea is that you have a collection class which interfaces between 
your code and the database module .. using your example you could have

Person.pm (which is what I called an item class) .. this contains - as 
you have said .. the attributes of a Person .. plus any accessor methods 
(an accessor method is just something like lastname_get and all it 
simply return the lastname attribute of Person - they're using to give a 
separation between the calling function and the data)

you would then have a collection class .. you might be able to get away 
with a generic collection class .. but for the time being let's assume 
that we can't .. and so we'll have a collection of Person objects called

Persons.pm (some people prefer a different naming convention here .. 
like Person_coll.pm or something .. my eyes are good - and so just 
adding an 's' for me works fine - up to you)

Persons.pm is where you will stick the save method that you're talking 
about .. the parameter to Persons::save will be a Person object .. the 
code in the program that uses these two classes might look something 
like this

  use Persons;
  my $collection = new Persons;

  use Person;
  $collection->save( new Person( $pId, $lName, $fName, $ssn));

>Right now, I have the sql embedded in the save method, so I pass the
>method a db connection ref and do the work.

in what I'm proposing the ONLY code that deals with the database is the 
collection class

in Persons.pm the save method will look something like this (note this 
code snippet ignores checking whether the record already exists and 
adjusting the insertion to an update - but basically you'd just use a 
different statement handle when you set $sth)

  sub save
  {
    my $self = shift;

    my $p = shift;

    # attach to the singleton
    my $dh = single UserDatabase;

    # grab a statement handle to the statement we're interested in
    my $sth = $dh->{person_insert_sth};

    # execute that statement passing in the relevant fields from Person
    my $ret = $sth->execute( @p{id, lastname, firstname, ssn} );

    $ret;
  }

>1. not have to always pass the methods a db handle

the UserDatabase.pm module (the database class) should really be the 
only one to deal with the DB handle directly .. you might want the 
collection class to as well - because you're lazy .. eg. to access the 
errstr function directly - instead of wrapping it up inside the database 
class (that's why you'll notice that I included the database handle as 
an attribute in the database class - so I can write $dh->{dbh}->errstr)

>2. store the sql globally somehow so I can easily modify the database
>structure if necessary without to much work on the class module.

this is the idea behind the database class .. all your SQL statements 
are pre-prepared in the one class which is a singleton (meaning that 
only one instance is ever created no matter how many times it is called)

so basically .. if the data changes then you change the database class 
 .. and possibly the item classes themselves

>Can I apply your concept somehow?  Would I just instantiate the
>UserDatabase and pass the correct statement handle to my class?

not from your program .. your program will deal only with the Person and 
Persons classes .. all accesses of the database are made via the 
collection class (Persons) .. it holds on to the database handle if 
needs be

>If I declare and create my db handle and statement handle in a script
>that "uses" my Person module at its beginning, can the Person object's
>methods "see" my $dh and $sth variables?

you're thinking the wrong way around .. you want to abstract the data 
store .. remove yourself from it and deal with it ONLY through the 
collection class .. so - as far as your program is concerned - it is 
accessing a collection of Person objects

that collection happens to be stored in a database - but your program 
doesn't know - or care where they are stored .. this not only means that 
changes to your database have minimal effect on your program but it also 
gives you the ability (if needs be) to do tricks with that collection

you might decide that there are going to be thousands of read operations 
and very few write operations .. so it might be worthwhile caching the 
data from the database in memory .. so the collection would hold those 
items and all your reads would be very quick

again - your program doesn't know or care about that caching .. it just 
cares that there are a collection of Person objects that it is able to 
interact with

-- 
 jason - elephant@squirrelgroup.com -


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

Date: 26 Jun 2000 08:15:54 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: User's details
Message-Id: <slrn8le498.p29.efflandt@efflandt.xnet.com>

On Sun, 25 Jun 2000, Raphael Pirker <raphaelp@nr1webresource.com> wrote:
>
>I've heard that you can find out user's details using perl. In which array
>or variable are they stored? I'm aiming at:
>
>Browser
>PC
>OS

This CGI question is not Perl related, but in Perl you can "try" to parse
$ENV{HTTP_USER_AGENT), but good luck!  Here are some examples:

Mozilla/4.0 (compatible; MSIE 5.0; AOL 5.0; Windows 95; DigExt)
Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; CDv5_0699)
Mozilla/4.0 (compatible; MSIE 4.01; MSN 2.6; Windows 95)
Mozilla/4.7 [en] (Win98; I)
Mozilla/4.7 [en] (X11; I; Linux 2.2.13 i586)
Mozilla/4.61 [en] (X11; I; Linux 2.2.12-20 i686)
Googlebot/2.0 beta (googlebot(at)googlebot.com)
Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)
Mozilla/4.08 [en] (WinNT; U ;Nav)
Slurp.so/1.0 (slurp@inktomi.com; http://www.inktomi.com/slurp.html)
Lycos_Spider_(T-Rex)

And when I grab a site to check the headers I use:
Perl/5.0 [en] (Unix script)

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

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


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