[16614] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4026 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 15 18:06:34 2000

Date: Tue, 15 Aug 2000 15:05:24 -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: <966377123-v9-i4026@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 15 Aug 2000     Volume: 9 Number: 4026

Today's topics:
    Re: [Perl] invalud method <lauren_smith13@hotmail.com>
        Autosplit "*.ix" file fgont@my-deja.com
    Re: being able to change the name of a file on the serv (Colin Keith)
    Re: being able to change the name of a file on the serv <star@sonic.net>
        Certain Items in a string marxjkj123@my-deja.com
        crypt function (Jonas Nilsson)
        DBI/DBD Oracle/Apache problem Erik.Dantes@wmich.edu
        Dereferencing a hash in CGI.PM joedevon@my-deja.com
    Re: Dereferencing a hash in CGI.PM joedevon@my-deja.com
    Re: edit multiple files with vi (Abigail)
    Re: edit multiple files with vi <jeff@yoak.com>
    Re: Get ip from visitor <sowinso@sowinso.com>
    Re: Get ip from visitor <jeff@vpservices.com>
    Re: Get ip from visitor <godzilla@stomp.stomp.tokyo>
    Re: Help a little needed from regex expert please (John Stanley)
    Re: Help a little needed from regex expert please (Abigail)
        Help: Strange results from Perl's umask function <rrasmussen@paragen.com>
    Re: Help: Strange results from Perl's umask function <newsposter@cthulhu.demon.nl>
    Re: Large Pieces of Code (Colin Keith)
    Re: Large Pieces of Code mr_curmudgeon@my-deja.com
    Re: Large Pieces of Code <russ_jones@rac.ray.com>
    Re: Large Pieces of Code (Logan Shaw)
    Re: need help with msql and perl (Colin Keith)
    Re: Negativity in Newsgroup -- Solution (Jon S.)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 15 Aug 2000 12:23:49 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: [Perl] invalud method
Message-Id: <8nc59b$j9j$1@brokaw.wa.com>


<bolero92@my-deja.com> wrote in message news:8na9q6$bc$1@nnrp1.deja.com...
>
> I have some questions:
> 1) What does the error "Invalid method in request quit" means?

If it's a Perl error, the perldiag document should contain an explanation.

> 2) When I change to:
> `/usr/bin/cp /etc/mail/aliases.save /etc/mail/aliases`;
> `/usr/bin/newaliases`;
>
> the first line can be executed, but the second line can't be executed,
> Why?

Is 'newaliases' an executable file?  This has more to do with your OS than
Perl, I'd ask in a newsgroup that was specific to your OS.

> 3) What is the difference between ` and system()?

While not exactly a FAQ, this question is very similar to perlfaq8: Why
can't I get the output of a command with system()?

Lauren
--
print grep ord $_,map{y/a-z//d;$x.="+ $_";chr(eval $x)}
'J74u43-s2tA1-84n33o45th1er5-12-P3e13-82r48l21H13-a6-76
c40k25er2wx8-y6z13-81'=~m#([^!\n]{3})#g#tr/-0-9//d;print





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

Date: Tue, 15 Aug 2000 21:15:24 GMT
From: fgont@my-deja.com
Subject: Autosplit "*.ix" file
Message-Id: <8ncbsq$muj$1@nnrp1.deja.com>

Dear guys,

I downloaded the MIME and Mail modules, and when I tried to execute a
simple test script, I got the message:

Can't locate auto/Mail/Internet/autosplit.ix
blahb, blah at C:\Perl\lib\AutoLoader.pm line 133

This file isn't in the zip files I downloaded, and I don't know if I
should use some tool to create them, or what.

What should I do?

Thank you very much in advance,

Fernando Ariel Gont

If you want to send a personal reply, please send it to:
fgont [at] softhome [dot] net




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


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

Date: Tue, 15 Aug 2000 18:40:04 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: being able to change the name of a file on the server,(here is the script)
Message-Id: <88gm5.137$DT4.3758376@nnrp2.clara.net>

In article <B5BE27B9.5C41%star@sonic.net>, arthur <star@sonic.net> wrote:
>in article B5BD1A3D.5687%star@sonic.net, arthur at star@sonic.net wrote on
>8/14/00 2:38 PM:
>> Suppose there is a file that runs in a learning application on a server and
>> I want different people to be able to change that file and save the version
>> they changed as their own but not erase the other peoples version?
>#!/usr/bin/perl -w
Good

>use IO File;
Why? The version of open() you're using is CORE::open()

>use strict;
v. good :)
>use File::Copy;
why? You don't use it

>    print (HOPE (param('$question')));
You not need as many paranthesis, but if it makes you happier ... :)

>symlink("name","dat.html") || die "cannot symlink to dat.html";
I don't quite understand what this is for either (could just be me being 
stupid though :)

Anyway:
  use File::Copy;
  copy($origfile, $mycopy) || die "Content-Type: text/plain\n\nUh oh - $!";
  chown($uid_of_copier, $gid_of_copier, $mycopy);
  open(FH, ">>$mycopy") || die "Content-Type: text/plain\n\nUh oh - $!";
  print FH "updated information...\n";

Save a copy of the original file as their own make changes (in this case 
append, see the perlfaqs on inserting/deleting lines in a file if you want 
to do that) Or if it should be the shared file that gets modified make the 
mods first, then copy it.

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Tue, 15 Aug 2000 20:36:14 GMT
From: arthur <star@sonic.net>
Subject: Re: being able to change the name of a file on the server,(here is the script)
Message-Id: <B5BE4EEE.5C6B%star@sonic.net>

>> in article B5BD1A3D.5687%star@sonic.net, arthur at star@sonic.net wrote on
>> 8/14/00 2:38 PM:
>>> Suppose there is a file that runs in a learning application on a server and
>>> I want different people to be able to change that file and save the version
>>> they changed as their own but not erase the other peoples version?
>> #!/usr/bin/perl -w
> Good
> 
>> use IO File;
> Why? The version of open() you're using is CORE::open()
oops :>
> 
>> use strict;
> v. good :)
>> use File::Copy;
> why? You don't use it
oops :>
> 
>> symlink("name","dat.html") || die "cannot symlink to dat.html";
> I don't quite understand what this is for either (could just be me being
> stupid though :)
I am sure you are not stupid I am just trying.

> use File::Copy;
> copy($origfile, $mycopy) || die "Content-Type: text/plain\n\nUh oh - $!";
> chown($uid_of_copier, $gid_of_copier, $mycopy);
> open(FH, ">>$mycopy") || die "Content-Type: text/plain\n\nUh oh - $!";
> print FH "updated information...\n";
> 
> Save a copy of the original file as their own make changes (in this case
> append, see the perlfaqs on inserting/deleting lines in a file if you want
> to do that) Or if it should be the shared file that gets modified make the
> mods first, then copy it.
> 
> Col.
> 
Thanks Col,

A few questions-- what is gid_of_copier? I know uid is user id but gid? Do I
need it if he permissions on this script are public in all areas?

I will get rid of the extra libraries. oops :>

Also do you know Allan Fry he is a MacPerl gentleman in your area. He helped
me alot a few years ago and I owe him a bottle of wine. I lost his address
however.

~arthur
star@sonic.net



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

Date: Tue, 15 Aug 2000 21:51:08 GMT
From: marxjkj123@my-deja.com
Subject: Certain Items in a string
Message-Id: <8nce05$p5e$1@nnrp1.deja.com>

Hello and thank you for all the previous help.  I have a problem that
I'm trying to solve.

Problem: I need to select certain items within a string.

for example, I have a string($iw_Workarea) and I need to select
everything from Workarea on and put it into a variable called $test.
Basically, omitting everything preceeding \\Workarea.

$iw_Workarea = "Y:\\default\\main\\Web_Logic\\Workarea\\WL_Property_WA

Result would should look like, $test = "Workarea\\WL_Property_WA";

MF


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


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

Date: Tue, 15 Aug 2000 23:24:48 GMT
From: jonas.nilsson@mbox326.swipnet.se (Jonas Nilsson)
Subject: crypt function
Message-Id: <3999d081.10891009@news1.tninet.se>

I have a text file with username:password, the password is crypt. I
want to have an: "e-mail me my password because I forgot it"
-function. When I do that I only get the crypted version. How do I
decrypt the password.

Thanks.
Jonas N


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

Date: Tue, 15 Aug 2000 20:00:12 GMT
From: Erik.Dantes@wmich.edu
Subject: DBI/DBD Oracle/Apache problem
Message-Id: <8nc7g0$ha5$1@nnrp1.deja.com>

I am having an intermitten problem.  I have a perl script that generates
web pages pulling data from an Oracle database.  I am using:
Perl: 5.00503
DBI: 1.13
DBD-Oracle: 1.03

I get this entry in the error_log:
DBD::Oracle::db prepare failed: ERROR Database disconnected at
/path/to/file/openwork.pl line 313.
[Tue Aug 15 0:57:49 2000] [error] Can't prepare SQL statement: ERROR
Database disconnected

Now if I reload the web page, _Most_ of the time, it will then run.  On
the occasions that it does not reload properly, if I give Apache a -HUP,
it always works.

At the beginning of the script I have:
$db=DBI->connect("dbi:Oracle:host=machine;sid=orcl","acct","password")
   || die "Connect Failed: $DBI::errstr";

I then call subroutines, and included in them are:
$sql = "SELECT stuff FROM table WHERE condition";
$cur = $db->prepare("$sql")
   || die "Can't prepare SQL statement: ", $db->errstr(), "\n";
$cur->execute()
   || die "Can't execute SQL statement: ", $cur->errstr(), "\n";
while (($stuff) = $cur->fetchrow_array) {
  do some things here...
}
warn "Problem in fetchrow_array(): ", $cur->errstr(), "\n"
   if $cur->err();


I often call multiple subroutines, some with database connections.
At the end of the script I have:
$db->disconnect()
   || warn "Failed to disconnect: ", $db->errstr(), "\n";


Looking through this, I notice I don't have any finish().  Could that be
part of it?  Anyhow.  Is there a way to capture the disconnection and
force a reconnect?  Any ideas are welcome.

Erik


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


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

Date: Tue, 15 Aug 2000 18:45:16 GMT
From: joedevon@my-deja.com
Subject: Dereferencing a hash in CGI.PM
Message-Id: <8nc33l$coq$1@nnrp1.deja.com>

How do you dereference a hash from within a tag in the CGI.PM? Here is
some test code, where the same variable, $result, is available as the
value, but when called from within "textfield
({name=>$result,default=>'test',size=>'40',maxlength=>'250'})"
the $result turns into a reference to a hash e.g.: "NAME="HASH
(0x14e290)". (Please note that you need to view source of the html page
that results from this cgi script.)

Here's the code:


#!/usr/local/bin/perl
use CGI qw(:standard :all);
%testvars = ('t1'=>'r1',
		't2'=>'r2',
		't3'=>'r3');

@test = "<center>Without using the tags from cgi.pm:<CENTER><BR>\n";
while (($test, $result) = each(%testvars)){
push(@test,"<center>test equals $test and result equals
$result</center><BR>\n");
push(@row,
	Tr({bgcolor=>'#FCF0C0'},
		td({width=>'50%',align=>'right'},
			font({size=>'2',face=>'Verdana, Arial'},
				b($test)
			)
		),
		td({width=>'50%',valign=>'top'},
			textfield
({name=>$result,default=>'test',size=>'40',maxlength=>'250'})
		)
	)
);
}

print	header();
print	start_html();
print center(h1("Test Script"));
print table
({border=>'0',bgcolor=>'#000000',width=>'90%',align=>'center'},
	Tr({bgcolor=>'#FCF0C0'},td({colspan=>'2'},@test)),
	@row
);
print	end_html();
1;


Thanks!!!!!


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


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

Date: Tue, 15 Aug 2000 20:11:46 GMT
From: joedevon@my-deja.com
Subject: Re: Dereferencing a hash in CGI.PM
Message-Id: <8nc85h$ib2$1@nnrp1.deja.com>

Dummy me. I had {} where I should not so
textfield
({name=>$result,default=>'test',size=>'40',maxlength=>'250'})

should be

textfield(name=>$result,default=>'test',size=>'40',maxlength=>'250')



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


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

Date: 15 Aug 2000 19:46:03 GMT
From: abigail@foad.org (Abigail)
Subject: Re: edit multiple files with vi
Message-Id: <slrn8pj7ep.tj3.abigail@alexandra.foad.org>

Lily Fu (lilyfu@bestedeal.com) wrote on MMDXLI September MCMXCIII in
<URL:news:3999763A.3858FFA5@bestedeal.com>:
}} OK,  I use CVS to check in, out and commit
}} programs in a team environment.
}} 
}} I made a massive change on a bunch of files,
}} and I need to make cvs commit for each of the files.
}} 
}} from command, when I type in
}} 
}} cvs commit filename
}} 
}} it opens a vi window and ask me to type in some
}} comment.
}} 
}} That is the reason I want to write a perl
}} to automatically insert some comment
}} into each CVS commit log using vi.
}} 


I think the appropriate action would be to check out the cvs manpages.



Abigail
-- 
perl -Mstrict -we '$_ = "goto R.print chop;\n=rekcaH lreP rehtona tsuJ";R1:eval'


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

Date: Tue, 15 Aug 2000 12:49:38 -0800
From: "Jeff Yoak" <jeff@yoak.com>
Subject: Re: edit multiple files with vi
Message-Id: <8nbvvc027bh@news1.newsguy.com>


[ posted and mailed ]

In article <qIem5.4274$K5.89729@typhoon.austin.rr.com>, mike@stok.co.uk
(Mike Stok) wrote:

> It's quite reasonable to set the CVSEDITOR enviromnment variable to a
> program other than vi, possibly your own perl script.

or use -m with the cvs commit so you can specify the message at the
command line, assuming your script isn't generating dynamic info for the
message.




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

Date: Tue, 15 Aug 2000 19:05:11 GMT
From: "Brian A. Sayrs" <sowinso@sowinso.com>
Subject: Re: Get ip from visitor
Message-Id: <Hvgm5.1233$3T4.254495@sea-read.news.verio.net>


<rune@clamon.dk> wrote in message news:8nanqf$9i1$1@nnrp1.deja.com...
> Hi,
> I want to get the ip-adress from the visitor on my homepage that
> executes my perl cgi-script. How is this possible?
>
> Regards,
> Rune Christensen - DK
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

Write a script which contains the following line:

foreach $key (keys %ENV) { print "$key -> $ENV{$key}<BR>\n" }

and you will find out lots of fascinating things about your guest.
--
Brian A. Sayrs
Owner, Southwind Solutions





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

Date: Tue, 15 Aug 2000 12:07:05 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Get ip from visitor
Message-Id: <399994D9.337D1B62@vpservices.com>

"Brian A. Sayrs" wrote:
> 
> <rune@clamon.dk> wrote in message news:8nanqf$9i1$1@nnrp1.deja.com...
> > Hi,
> > I want to get the ip-adress from the visitor on my homepage that
> > executes my perl cgi-script. How is this possible?
> >
> > Regards,
> > Rune Christensen - DK
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> 
> Write a script which contains the following line:
> 
> foreach $key (keys %ENV) { print "$key -> $ENV{$key}<BR>\n" }
> 
> and you will find out lots of fascinating things about your guest.

Correction:  you will find out lots of things that your guest wants you
to believe but that may or may not be true.

-- 
Jeff


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

Date: Tue, 15 Aug 2000 12:48:22 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Get ip from visitor
Message-Id: <39999E86.2C2E4DF7@stomp.stomp.tokyo>

Jeff Zucker wrote:
 
> "Brian A. Sayrs" wrote:
> > rune wrote:

> > > I want to get the ip-adress from the visitor on my homepage that
> > > executes my perl cgi-script. How is this possible?

> > Write a script which contains the following line:

> > foreach $key (keys %ENV) { print "$key -> $ENV{$key}<BR>\n" }

> > and you will find out lots of fascinating things about your guest.
 
> Correction:  you will find out lots of things that your guest wants you
> to believe but that may or may not be true.


Making an educated guesstimation, Mr. Zucker, I would say
environmental variable information is correct, hmm.. somewhere
between eighty-five to ninety-five percent upon return. False
or incorrect information is a function of privacy fear or,
most often, malice intent. A majority of internet users are
not all this worried about host name and IP address privacy.
Fear motivation seems to more concern issues of invading a
home system's files, virii, trojans and the such. Much of 
these fears are media hype to sell guard dog type software
which are most often, useless and an annoyance. This is not
to say these fears are not legitimate but rather to say they
are exaggerated by profit motivation and media hype.

Each variable, however, will show dramatic differences in rate
of relative accuracy. What you say about true or not true, does
certainly apply to a host name and related IP address. Anonymous
proxies are quite common these days. Another guesstimation, I have
found I can pull a true host name or IP address, including those
behind a firewall, with ninety to ninety-five percent accuracy.
There are some tricks, perhaps mildly objectionable, which will
return a host name, if available, and certainly a true IP address,
with a solid ninety-nine percent accuracy. Remaining one percent 
applies to those with non-industry standard systems, such as Linux,
which require little known operating system specific tricks.

Among the least often changed environmental variables, based on
statistics showing which browser types are most often used, is
just that, browser / system information. Dismissing browsers
which are not industry standard, Mozilla and MSIE are the leaders
for browser usage, a point beyond debate. Faking browser information
through these binary executables, is challenging. Nonetheless, you
will notice my Mozilla browser information is,

" Mozilla/GODZILLA! GO GO GODZILLA! "

So yes, some but not all environmental variables cannot be trusted
completely but, an effective programmer can increase her or his odds
of attaining correct information with good planning and good thinking.

For casual common day programs, these issues are not all that
important really. When it comes to security concerns though,
these issues become most critical and should be well addressed.

Godzilla!


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

Date: 15 Aug 2000 19:00:11 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Help a little needed from regex expert please
Message-Id: <8nc3vr$g4c$1@news.NERO.NET>

In article <VGdm5.133$DT4.3740365@nnrp2.clara.net>,
Colin Keith <newsgroups@ckeith.clara.net> wrote:
>In article <4P2m5.63$ZC2.4296@nsw.nnrp.telstra.net>, "Robert Chalmers" <robert@chalmers.com.au> wrote:
>>What I need to do is extract ONLY the word  between the "", ie, in this
>>case - CCSCHINO.COM
>
>/^No match for "([A-Z0-9]{3,60}\.[A-Z]{3})\"\.$/;

What if there is no period in the "word" between ""? What if there are
lower case characters? What if there are non-alphunumeric?

>I think domain names have a minimum of 3 and max of 60

I think not. You are in the UK -- how many characters are in YOUR top
level domain? And the fellow you are telling this to is in Oz, with
a .au address. 

>I have a question in turn, why does turning the [A-Z]{3} into 
>[A-Z][A-Z][A-Z] make it slower? I would have assumed that the evaluation is 
>the same, but Benchmark tests give:
>
>perl -w -Mstrict -MBenchmark
>timethese(100000, {
>  three => sub { $_ = 'No match for "CCSCHINO.COM".';
>                 /^No match for "([A-Z0-9]{3,60}\.[A-Z]{3})\"\.$/; },
>  fixed => sub { $_ = 'No match for "CCSCHINO.COM".';
>                 /^No match for "([A-Z0-9]{3,60}\.[A-Z][A-Z][A-Z])\"\.$/; }
>});
>Benchmark: timing 100000 iterations of fixed, three...
>     fixed:  2 wallclock secs ( 1.72 usr +  0.00 sys =  1.72 CPU)
>     three:  2 wallclock secs ( 1.76 usr +  0.01 sys =  1.77 CPU)

You're kidding, right? What happens if you run this test ten times?
Why do you think that 40ms is significant, considering that you are
running this on an operational system?



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

Date: 15 Aug 2000 19:53:32 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Help a little needed from regex expert please
Message-Id: <slrn8pj7sq.tj3.abigail@alexandra.foad.org>

Colin Keith (newsgroups@ckeith.clara.net) wrote on MMDXLI September
MCMXCIII in <URL:news:VGdm5.133$DT4.3740365@nnrp2.clara.net>:
:) 
:) I have a question in turn, why does turning the [A-Z]{3} into 
:) [A-Z][A-Z][A-Z] make it slower? I would have assumed that the evaluation is 
:) the same, but Benchmark tests give:
:) 
:) perl -w -Mstrict -MBenchmark
:) timethese(100000, {
:)   three => sub { $_ = 'No match for "CCSCHINO.COM".';
:)                  /^No match for "([A-Z0-9]{3,60}\.[A-Z]{3})\"\.$/; },
:)   fixed => sub { $_ = 'No match for "CCSCHINO.COM".';
:)                  /^No match for "([A-Z0-9]{3,60}\.[A-Z][A-Z][A-Z])\"\.$/; }
:) });
:) Benchmark: timing 100000 iterations of fixed, three...
:)      fixed:  2 wallclock secs ( 1.72 usr +  0.00 sys =  1.72 CPU)
:)      three:  2 wallclock secs ( 1.76 usr +  0.01 sys =  1.77 CPU)
:) 
:) (And this time I tested it is matching correctly :)
:) Pointers on where to look for details? (I did see the URLs in the 'grep() 
:) optimisation' thread, but haven't had chance to read them yet :)


This once again shows Benchmarking is an art, and utterly useless if you
don't know what you are doing.

If you run your benchmark a dozen times or so, you'll find that the 
variance between the runs is more than the difference between the cases.

Don't attribute "faster" to noise.


Abigail
-- 
perl -Mstrict -we '$_ = "goto F.print chop;\n=rekcaH lreP rehtona tsuJ";F1:eval'


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

Date: Tue, 15 Aug 2000 21:38:19 GMT
From: Roger Rasmussen <rrasmussen@paragen.com>
Subject: Help: Strange results from Perl's umask function
Message-Id: <3999B8E1.A6EC16CE@paragen.com>

This is a multi-part message in MIME format.
--------------F7EA799907103B825A4738F7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I'm getting some result from the 'umask' function in Perl that I can
only call bizarre.

Here is my source code:

umask(000);
print "umask=",umask(),"\n";

This prints out umask=0, which makes sense.

Now if I make the following change:

umask(777);
print "umask=",umask(),"\n";

This prints out umask=265 ????

Any umask value I give it that is <= 511 will display exactly that
number later on, but any umask(512) or greater will display that value
minus 512, for example.

umask(000);
print "umask=",umask(),"\n";      # displays umask=0

umask(511);
print "umask=",umask(),"\n";      # displays umask=511

umask(512);
print "umask=",umask(),"\n";      # displays umask=0

umask(623);
print "umask=",umask(),"\n";      # displays umask=111

Anyone know why this is happening?

Roger Rasmussen


--------------F7EA799907103B825A4738F7
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Roger Rasmussen
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Roger Rasmussen
n:              Rasmussen;Roger
org:            Paradigm Genetics
adr;dom:        104 Alexander Drive;;P.O. Box 14528;Research Triangle Park;NC;27709-4528;
email;internet: rrasmussen@paragen.com
title:          Software Engineer
tel;work:       (919) 425-3029
tel;fax:        (919) 544-8094
tel;home:       (919) 832-5951
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
version:        2.1
end:            vcard


--------------F7EA799907103B825A4738F7--



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

Date: 15 Aug 2000 21:57:17 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Help: Strange results from Perl's umask function
Message-Id: <8ncebt$nm5$1@internal-news.uu.net>

Roger Rasmussen <rrasmussen@paragen.com> wrote:
> This is a multi-part message in MIME format.

Please don't do that.

> I'm getting some result from the 'umask' function in Perl that I can
> only call bizarre.

> umask(777);
> print "umask=",umask(),"\n";

> This prints out umask=265 ????

  I bet it gets a lot less bizarre if you realize umask expects an
octal number. So try 0777 instead of 777 ...

Erik



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

Date: Tue, 15 Aug 2000 18:18:46 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Large Pieces of Code
Message-Id: <aQfm5.136$DT4.3755488@nnrp2.clara.net>

In article <g60m5.44012$eS6.783649@news1.rdc1.md.home.com>, "Robert Brooks" <studentfl@hotmail.com> wrote:
>to break it down so it runs faster and doesn't take up as much space in
>memory? I was thinking of doing the module approach... having different
>modules, perl scripts themselves, and every time a user does a function it
>is handled by a different module of the script. That is one way, but it
>requires a little extra effort in sharing variables amoung the different
>modules.

That depends if your one script has multiple sections that do completely 
different things - I.e. "If I'm called with the name ... do this" or "If my 
args are .. do something totally different than if they're ..." then yes, 
you can benefit from pulling bits out. Take the core functions, say 
update_db() and log_to_file() into a module and break the program up into 
update_script.pl, create_script.pl, etc.. If it is one program then its 
harder. Because everything is needed and has to be loaded.

That said, it isn't going to be the size of your Perl script that you need 
to worry about, but what's actually executed by the interpretter. The 
executable will be much huger than your script :)

You are probably better off looking at how to optimise your program rather 
than its physical size. Can you precompute your arrays, use tr// instead of 
s//. Can your regexps use /o and not use $& $' $`, can you use study() (no 
I've never used it, dun't understand it :-( :) Are you declaring loads of 
variables that you don't need to? Perl doesn't have on the fly garbage 
collection, but when the reference count for a variable drops to 0, the 
memory it uses will be marked as available and can be reused by other 
variables you allocate. There is an FAQ entry somewhere (search the 
perlfaq's) that explains that some OS's don't allow you to return unused 
memory back to the heap, so some programs will re-exec themselves so the 
original copy of the program stops and the OS claims back all of the memory 
used. But this is usually daemons and witches and things so probably doesn't 
apply here:)

>Are there any other ways? If I do "require" statements to require different
>pieces of code, are those going to parsed before the program is run, thus
>defeating the purpose of having different pieces of code in different files.

documentation! :) perlfaq8
=head2 What's the difference between require and use?

Its far more concise than me :)

>Besides optimizing the code so the script isn't so big (already done), are
>there other ways to reduce the server's load? Thanks

su root -c 'kill -9 -1' :)

If you've optimised the script, maybe you can look into something like 
the Apache module ModPerl or modules from CPAN to help speed things up  
(CGI::Speedy?), zap anything you don't need to be running on the machine 
itself or in the server (if that's possible) Of course, Benchmark is handy 
for testing any changes to see if they do improve things. And of course you 
can always try extra things like keeping the minimum number of variables 
around - not reading the entire file into an array, but read it line at a 
time. Perhaps using tailored algorithms - using a particular form of 
sort routine optimised for your data rather than perl's built-it quick sort, 
perhaps playing with Heap::* from Cpan rather than just a standard array, 
tie your hashes to disk files, etc.

Some ideas mebbe :)

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Tue, 15 Aug 2000 19:25:10 GMT
From: mr_curmudgeon@my-deja.com
Subject: Re: Large Pieces of Code
Message-Id: <8nc5e7$f5e$1@nnrp1.deja.com>

In article
<g60m5.44012$eS6.783649@news1.rdc1.md.home.com>,
  "Robert Brooks" <studentfl@hotmail.com> wrote:
> Question, I am writing a large program and I am trying to find a
good way to
> lessen the load on my server. The code is around 200kb. What
is the best way
> to break it down so it runs faster and doesn't take up as much
space in
> memory?

Rewrite it in Java.


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


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

Date: Tue, 15 Aug 2000 15:32:25 -0500
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: Large Pieces of Code
Message-Id: <3999A8D9.12F579AC@rac.ray.com>

mr_curmudgeon@my-deja.com wrote:
> 
> 
> Rewrite it in Java.
> 

puh-LONK
-- 
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747

Quae narravi, nullo modo negabo. - Catullus


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

Date: 15 Aug 2000 15:52:52 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Large Pieces of Code
Message-Id: <8ncaj4$863$1@provolone.cs.utexas.edu>

In article <g60m5.44012$eS6.783649@news1.rdc1.md.home.com>,
Robert Brooks <studentfl@hotmail.com> wrote:
>Question, I am writing a large program and I am trying to find a good way to
>lessen the load on my server. The code is around 200kb. What is the best way
>to break it down so it runs faster and doesn't take up as much space in
>memory?

I don't think you're going to have too much luck making it take less
space in memory.  You have a certain amount of code, and that's just
the way it is.  You could do some kind of elaborate trick to load only
those parts which are being used, but that would be kind of a waste
since that's what the virtual memory subsystem of your operating system
is supposed to do for you.  In other words, don't worry about this
too much -- let the operating system worry about it for you.

Having said all that, I'm going to now assume that you're actually
talking about a CGI that runs too slowly because it takes too much time
for the perl interpreter to load and then interpreter your script.
If that's your problem, there are several solutions:

1.  Rewrite the whole thing using mod_perl.
2.  Convert it to be a FastCGI script -- see http://www.fastcgi.com/ .
3.  Make your program into a daemon that accepts connections on a
    socket, then have the CGI be a short script that simply connects
    to the daemon and relays the input and output back and forth.

Actually, if I understand FastCGI correctly, #2 and #3 aren't all that
different.

Hope that helps.

  - Logan


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

Date: Tue, 15 Aug 2000 18:49:39 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: need help with msql and perl
Message-Id: <7hgm5.138$DT4.3759242@nnrp2.clara.net>

In article <8nar9b$8gd$1@slb7.atl.mindspring.net>, "karamazov" <karamazov@mindspring.com> wrote:
>i am writing a script using the dbd::msql driver to access a small msql db.
>the prob i have is with a query i am trying to process.  here is the code
>for it:
>
>my $dbh=DBI->connect($db, $dbName);
>my $statement= "select mov_index, mov_title, mov_year,mov_rating from movie
>where mov_avail= 'Y'   \g";
>my $sth=$dbh->prepare($statement);
>
>for some reason the query won't execute when i call $sth->execute.  i get
>parse errors.  what is wrong with this?

I wouldn't have thought you'd need the \g, you don't in MySQL and the 
DBI are distributed together so I'm *guessing* they're not that disimilar. 
You should also check that your connect succeeded, are you sure its not 
complaining about $dbh not being an object because the connect failed? 
$DBI::errstr should tell you what errors you're getting from the DB.

Col.
>
>
>
>
>


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Tue, 15 Aug 2000 18:21:48 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: Negativity in Newsgroup -- Solution
Message-Id: <39998a14.18466098@news.earthlink.net>

On Mon, 14 Aug 2000 18:33:11 +0200, Abe Timmerman
<abe@ztreet.demon.nl> wrote:

>On Mon, 14 Aug 2000 16:10:37 GMT, jonceramic@nospammiesno.earthlink.net
>(Jon S.) wrote:
>
>> On 14 Aug 2000 07:26:00 GMT, ebohlman@netcom.com (Eric Bohlman) wrote:
>> 
>> >Drew Simonis (care227@attglobal.net) wrote:
>> >: Methinks the Schwartz is growing weary.
>> >
>> >I don't think Randal was expecting the Spanish Inquistion.
>> 
>> Nooobody expects the Spanish Inquisition!
>> 
>> Our only principle is:
>> 
>> "Use Strict;"
>
>Can't locate object method "Use" via package "Strict"

So, how do I hold up my hands to my head in an "N" for newbie?  :)

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


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