[10532] in Perl-Users-Digest
Perl-Users Digest, Issue: 4124 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 1 17:07:24 1998
Date: Sun, 1 Nov 98 14:00:22 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 1 Nov 1998 Volume: 8 Number: 4124
Today's topics:
Re: ANN: "pgrep" = perl grep (clay irving)
Re: Compare 2 files <simon@ouweb.com>
Re: Compare 2 files <r28629@email.sps.mot.com>
CPU usage <webmaster@eswap.co.uk>
Re: file sorting sar files in AIX <gellyfish@btinternet.com>
Re: Function Parameters? (David Alan Black)
general questions about perl from newbie <vkaasa@c2i.net>
Re: general questions about perl from newbie (Jon Bell)
Re: HELP! alarm doesn't work during gethostbyaddr() (Charles DeRykus)
Re: HTML rendering to GIF/JPEG output <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: It works , but why <r28629@email.sps.mot.com>
Re: It works , but why (Craig Berry)
Re: It works , but why (Tad McClellan)
module interface design (Leo Schalkwyk)
parsing email address problem jlafosse@my-dejanews.com
Re: perl and oracle <gellyfish@btinternet.com>
Problems with GD on Win32 <meint.post@tref.nl>
Re: Problems with GD on Win32 <meint.post@tref.nl>
Re: Searching with perl <gellyfish@btinternet.com>
Re: Searching with perl <Pap22@erols.com>
Re: system statistics from Perl <rproctor@together.net>
Re: What is the "correct" location of perl under Solari <r28629@email.sps.mot.com>
Re: What is the "correct" location of perl under Solari <ljz@asfast.com>
Re: What's with these Curly brackets??? (John Hardy)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 1 Nov 1998 08:48:39 -0500
From: clay@panix.com (clay irving)
Subject: Re: ANN: "pgrep" = perl grep
Message-Id: <71horn$1j6@panix.com>
In <71cs77$hk7$1@en1.engelschall.com> sb@engelschall.com (Steffen Beyer) writes:
>In comp.lang.perl.misc clay irving <clay@panix.com> wrote:
>>>Where is something comparable to The Perl 5 Module List for
>>>scripts?
>> Perl Reference?
>> http://reference.perl.com
>Thanks for the hint!
>The problem is none of the other tools that have been suggested here in
>this thread figure under the category "text tools" (as one would expect)
>on that page...
Does now! :)
--
Clay Irving
clay@panix.com
------------------------------
Date: 01 Nov 1998 04:55:09 PST
From: "Simon B." <simon@ouweb.com>
Subject: Re: Compare 2 files
Message-Id: <71hlnd$h9l@journal.concentric.net>
Hi, This is my script that I have to work with:
(Is this ok to compare 2 files and delete one line in one of the two)
open(COMPARE, $compare) || die "Can't open";
open(OUTPUT, $outfile) || die "Can't open";
@list=<REPORT>;
@compare=<COMPARE>;
$report=0;
while ($report - 1 < $#list)
{
$i = 0;
print $i;
while ($i - 1 < $#compare)
{
if ( $compare[$i] = $list[$r])
{
Tad McClellan wrote in message <2lvg17.q58.ln@flash.net>...
>Simon B. (webmaster@ouweb.com) wrote:
>: Hello, I need a CGI perl script that can compare 2 files and if it find
>: duplicate entries in one of the two files than it delete one line in one
of
>: the database...
>
>: Please answer me...
> ^^^^^^
>
> OK, but you didn't ask a question... ;-)
>
>
> Show us the code you have so far, and we will help you
> make it work.
>
>
>--
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Sun, 01 Nov 1998 09:02:22 -0500
From: Tk Soh <r28629@email.sps.mot.com>
To: "Simon B." <webmaster@ouweb.com>
Subject: Re: Compare 2 files
Message-Id: <363C69ED.B6845211@email.sps.mot.com>
Simon B. wrote:
>
> Hello, I need a CGI perl script that can compare 2 files and if it find
> duplicate entries in one of the two files than it delete one line in one of
> the database...
Well, let's see. First you sent a 'test', then you ask for a CGI... and both
are posted to the wrong ng <sigh>
> Please answer me...
> Thank you for your support
No thanks.
------------------------------
Date: Sun, 1 Nov 1998 12:15:21 -0800
From: "E-swap" <webmaster@eswap.co.uk>
Subject: CPU usage
Message-Id: <71ig4k$ebe$1@nnrp3.snfc21.pbi.net>
Hi
What are the main contributors in Perl scripts which affect the CPU usage of
a server.
I have a script which generates a lot of dynamic HTML pages, is this the
main factor, or are there other things I should be trying to tidy up.
Quite a general question I know but hope someone has ideas.
Regards and thanks,
Darren
------------------------------
Date: 1 Nov 1998 19:07:43 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: file sorting sar files in AIX
Message-Id: <71ibhv$36v$1@gellyfish.btinternet.com>
On Fri, 30 Oct 1998 20:32:23 GMT jistdc1@mail.jbhunt.com wrote:
> I am using sar to create reports that are stored in /var/adm/sa:
>
> -rw-r--r-- 1 adm adm 70768 Oct 22 23:00 sa22
> -rw-r--r-- 1 adm adm 70768 Oct 23 23:00 sa23
> -rw-r--r-- 1 adm adm 38608 Oct 24 23:00 sa24
>
> These are binary files that have to be viewed using sar -f saxx.
>
> I would like to create a script that runs on Fridays and uses sar -f on files
> from Thursday to Thursday. If it were run today, it would do something like:
>
> sar -f sa22 > sa1022
> .
> .
> sar -f sa29 > sa1029
>
> Once I have the saMMDD files, I will then ftp them to my PC. The ftp stuff I
> can handle, it's the perl code I can't.
>
Well that's a shame because this is something that is easily accomplished
with Perl and as a general rule we like to see "Some Code That You Have Tried
And Found Not To Work" (SCTYHTAFNTW ;-) so we can help you.
However some assistance can be found through 'man perlfunc' and the
functions
opendir
readdir
stat
system
localtime
you will probably want to check out the manpages 'perlsyn' and 'perlfaq'
also.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 1 Nov 1998 08:10:47 -0500
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: Function Parameters?
Message-Id: <71hmkn$ihk$1@pilot.njin.net>
miker3@ix.netcom.com (Michael Rubenstein) writes:
>On 31 Oct 1998 21:24:30 -0500, dblack@pilot.njin.net (David Alan
>Black) wrote:
>>miker3@ix.netcom.com (Michael Rubenstein) writes:
>>
>>>On Sat, 31 Oct 1998 22:21:23 GMT, Ricardo Dague <trikiw@hotmail.com>
>>
>>> my ($a) = @_;
>>> my ($i, $j);
>>
>>If you're initializing only one scalar from @_, it's better to shift,
>>in part because parens around the one argument to my() are optional
>>and might come and go.....
>I mention below that shift may be used. However, I generally prefer
>the form I gave since it is clearer when there is more than one
>parameter. The three most important things in programming are
> 1. Consistency
> 2. CONSISTENCY!
> III. consistency.
>Furthermore, I generally prefer not to modify an array with shift when
>my only purpose is to get the first element.
Yes, I am probably being too quick to shift. Perhaps the ugly
$a = $_[0]; comports more with what I'm claiming to want to achieve.
Somehow "my ($a) = @_;" always leaves me wondering: what about the
rest of @_? I know that reaction doesn't correspond directly to
anything wrong with the syntax, but I instinctively try to steer
around it.
Consistency, eh? Hey, I'll try anything once - even that :-)
David Black
dblack@pilot.njin.net
------------------------------
Date: Sun, 1 Nov 1998 17:29:29 +0100
From: "Vegard Kesa" <vkaasa@c2i.net>
Subject: general questions about perl from newbie
Message-Id: <71i1f0$9hn$1@news1.c2i.net>
Is perl a script language only?
In what environments do you code perl? Can you use a regular texteditor?
Thanks,
Vegard
------------------------------
Date: Sun, 1 Nov 1998 16:24:46 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: general questions about perl from newbie
Message-Id: <F1r49A.8Ls@presby.edu>
In article <71i1f0$9hn$1@news1.c2i.net>, Vegard Kesa <vkaasa@c2i.net> wrote:
>Is perl a script language only?
Perl is probably best thought of as a script language, but the interpreter
compiles a script completely into a sort of byte-code (I think) before
actually executing it.
>In what environments do you code perl? Can you use a regular texteditor?
You can use any text editor for writing code. I usually use 'pico' on a
Unix or Linux box. One of these days I'll probably switch to emacs, when
I get enough time to learn it well.
--
Jon Bell <jtbell@presby.edu>
------------------------------
Date: Sun, 1 Nov 1998 21:36:43 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: HELP! alarm doesn't work during gethostbyaddr()
Message-Id: <F1rIp7.KCD@news.boeing.com>
In article <71f061$s14$1@nnrp1.dejanews.com>,
<eric4242@my-dejanews.com> wrote:
>Hi,
>
>I'm using the following simple code to try to set a timer for
>the gethostbyaddr() function. Unfortunately, the arrival of
>the ALRM signal does NOT seem to interrupt the running gethostbyaddr()
>function. Any suggestions? gethostbyaddr() doesn't take any
>sort of argument for a maximum number of seconds to wait for
>a reply, and the only other thing I can think of is to compile
>into the Perl interpreter support for C's setjmp() and longjmp()
>functionality (which I'd rather not do!)
>
>sub TrapTimeout
>{
> $TIMED_OUT = 1;
>}
>
>
>$SIG{'ALRM'} = 'TrapTimeout';
>
>alarm(3);
>$TIMED_OUT = 0;
>
># $_addr is the appropriately 'packed' x.x.x.x address
>($_name, $_aliases, $_type, $_len, @_addrs) = gethostbyaddr($_addr, 2);
>alarm 0;
>
>if ( $TIMED_OUT )
>{
> $_name = "???";
>}
>
>
>Note again that my code works fine unless gethostbyaddr() isn't able
>to resolve the IP label, in which case it can take a long time for it
>to finally return. I'd like to set a 3-second timeout (which I am
>trying to do above with alarm, but to no avail...)
>
block C<eval> is Perl's setjmp/longjmp trapping mechanism.
perldoc perlfaq8
perldoc -f eval
perldoc perlipc | grep eval.
e.g.,
eval {
local $SIG{ALRM} = sub { die "timed out" };
alarm 3;
gethostbyaddr...
alarm 0;
};
if ($@ =~ /^timed out/) {
...
} elsif ($@) { die $@ }
hth,
--
Charles DeRykus
------------------------------
Date: 01 Nov 1998 22:45:45 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: HTML rendering to GIF/JPEG output
Message-Id: <83pvb7nl2u.fsf@vcpc.univie.ac.at>
Re: HTML rendering to GIF/JPEG output, Joe
<joeb@dadaware.com> said:
Joe> render each html page in a thumbnail form - it would
Joe> render the page and then spit out a GIF or JPEG
Joe> thumnailed version. Do you know of any tool for doing
Joe> so? This needs to be done in an automated fashion,
Joe> ideally under Unix.
perldoc GD
http://www.perl.com/CPAN
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Sun, 01 Nov 1998 08:57:33 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: It works , but why
Message-Id: <363C68CC.21E81316@email.sps.mot.com>
Lloyd Zusman wrote:
> The 'and' operator in Perl is a "short circuit" operator. What that
One of the nice Perl features that you either hate or love. I actually have
seen people got "short circuit'ed" and gave up Perl. <sigh>
-tk
------------------------------
Date: 1 Nov 1998 17:00:19 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: It works , but why
Message-Id: <71i434$7ua$1@marina.cinenet.net>
Tk Soh (r28629@email.sps.mot.com) wrote:
: > The 'and' operator in Perl is a "short circuit" operator. What that
:
: One of the nice Perl features that you either hate or love. I actually have
: seen people got "short circuit'ed" and gave up Perl. <sigh>
I'd be curious to hear how someone got annoyed by short-circuiting. I
find it universally good. However, this may be due to my background in
other short-circuiting languages.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "Ripple in still water, when there is no pebble tossed,
nor wind to blow..."
------------------------------
Date: Sun, 1 Nov 1998 11:23:56 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: It works , but why
Message-Id: <cf5i17.4ca.ln@flash.net>
Owen Cook (rcook@pcug.org.au) wrote:
: In a file creation routine, I used this line (adapted from someone elses)
: but didn't know why it worked.
Danger Will Robinson!
: ($j < 10) and ($j = "00$j");
: So I replaced it with this.
: if ($j < 10){$j = "00$j"}
Same thing, as Lloyd's followup explained.
: #!/opt/contrib/bin/perl
You should put a -w there.
You should do this with every Perl program.
Really.
Every time.
#!/opt/contrib/bin/perl -w
: #$summary_file = 'tassets.txt';
: open (FILE,"tassets.txt") or die "Couldn't open the file $!\n";
: $j=0;
: while (<FILE>){
: @rows = split ("\t");
: $j=$j+1;
$j++;
: #($j < 10) and ($j = "00$j");
: if ($j < 10){$j = "00$j"}
: ($j >9) and ($j<100) and ($j = "0$j");
$j = sprintf "%04d", $j; # format to 4 digits with leading zeros
: $a="Assets$j";
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 1 Nov 1998 18:25:28 GMT
From: schalkwy@minnie.RZ-Berlin.MPG.DE (Leo Schalkwyk)
Subject: module interface design
Message-Id: <71i92o$qfs$1@fu-berlin.de>
I often need to make illustrations depicting genetic maps. This is
really a specialised plotting operation, but I haven't found a general
tool kit that makes this job easy. I have written nasty one-off
PostScript-generating awk scripts in the past, but this time I'd like
to make a tidy, reusable perl module. I wonder if anybody can offer
advice on the most practical interface.
The stone-age (but functional) version I have so far has 3 subs, one
each to write the top and tail of the ps file, each to be called
once, and another to be called repeatedly which draws map segments.
Everything the module needs to know is passed through a somewhat
complicated list of parameters (see extract of pod below). This
means the calling program only has to worry about these 3 lists, but
on the other hand when you are forced to add yet another
parameter... Is there a smarter alternative? A slightly more
self-documenting variation would I suppose be a flattened hash.
Leo
=head1 SYNOPSIS
use MapDraw3 qw( &ps_top &ps_draw &ps_tail );
&ps_top(fh,width_cm,height,top_margin,left_margin_cm,
font, paper_format, no_of_maps,length_1 .. length_n);
&ps_draw(fh,map_no,lcolor,tcolor,broke,int,top_end,marker, tonext);
&ps_tail(fh);
# fh : filehandle. Must be qualified (eg main::OUTFILE)
# map_no: count from 0!
# length_1 etc are in maps4 own units (eg cM)
# int: interval lengths displayed if 1, not if 0 or "".
--
------------------------------------------------------------
schalkwy@mpimg-berlin-dahlem.mpg.de
Max-Planck-Institut f|r molekulare Genetik
Ihnestra_e 73
14195 Berlin-Dahlem
tel +49 30 84 13 1339
fax +49 30 84 13 1380
------------------------------
Date: Sun, 01 Nov 1998 15:54:12 GMT
From: jlafosse@my-dejanews.com
Subject: parsing email address problem
Message-Id: <71i074$dd8$1@nnrp1.dejanews.com>
Hi,
I am trying to parse all of the email addresses out of my guestbook. I can
successfully parse out the following:
<a href="mailto:blah@blah.com">
However some of my entries are recorded as such:
<a href="mailto:blah@blah.com?subject=blah">
This is where I have a problem in my regex. I am not sure how to check for a
'?' and if it exists parse it at that point, if not then parse it at the
ending '"'
Here is my code:
#! /usr/local/bin/perl
open(FILE, "guestbook.html");
while (<FILE>){
if (/<a href="mailto:(.*\@.*)">/){
$email = $1;
open(OUT, ">>guestbook.txt");
print OUT "$email\n";
close (OUT);
}
}
close (FILE);
Any help on this is appreciated.
Thanx,
Jason L.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 1 Nov 1998 18:29:21 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: perl and oracle
Message-Id: <71i9a1$36l$1@gellyfish.btinternet.com>
On Sat, 31 Oct 1998 00:34:07 GMT Alan Melton <arm@home.net> wrote:
> Is there any active link yet between perl 5 and
> oracle or is oraperl only applicable for perl 4.
>
DBD::Oracle is available from CPAN
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sun, 1 Nov 1998 14:34:56 +0100
From: "M.E. Post" <meint.post@tref.nl>
Subject: Problems with GD on Win32
Message-Id: <71ho3g$93d$1@reader3.wxs.nl>
Hello everybody,
I've just spent 4 hours browsing through DejaNews and my GD documentation
but I can't seem to solve this problem. I would be very grateful if someone
in this newsgroup could give me a hint for this problem. I'm using
Activestate Perl 5.005 on a Windows 98 machine and I have the GD module
correctly installed.
The problem I'm facing regards the failure of saving GIF images to disk that
were created with the GD module. I've tried several suggestions but none are
working out correctly.
This suggestion was found in DejaNews but it doesn't work. I'm probably
doing something wrong but don't know what:
$myPath = "foo.gif";
$im->gif($myPath);
I've set STDOUT to binmode but that didn't work either. A file is created
but with zero content.
Another solution that did give output was:
binmode FILE;
open( FILE, ">foo.gif" ) || die "Error: $!";
print FILE $im->gif;
close( FILE );
But the output is garbled, it's very small and it's smeared.
Can someone point me to a working solution or give me a hint as what it is I
am doing wrong? I would be very much obliged!
Bye,
Meint
Here follows the complete code with the exception of various "save" trial
code
#!/perl/bin/perl
use CGI qw(:standard);
use GD;
$q = new CGI;
$hallo = param("hoogte");
print "Content-type: image/gif\n\n";
# create a new image
open (GIF,"thermometer2.gif") || die;
$im = newFromGif GD::Image(GIF) || die;
close GIF;
open (GIF,"pijl.gif") || die;
$pijl = newFromGif GD::Image(GIF) || die;
close GIF;
$im->copy($pijl,80,460,0,0,74,16);
open(GIF,"textureorange.gif") || die;
$tile = newFromGif GD::Image(GIF);
$im->setTile($tile);
# draw the rectangle, filling it with the pattern
$im->filledRectangle(58,$hallo,79,560,gdTiled);
--
"Where shall I begin? Begin at the beginning and then proceed to the end"
Alice in Wonderland - Lewis Carroll
mailto: meint.post@tref.nl
------------------------------
Date: Sun, 1 Nov 1998 15:52:54 +0100
From: "M.E. Post" <meint.post@tref.nl>
Subject: Re: Problems with GD on Win32
Message-Id: <71hslm$p3i$1@reader3.wxs.nl>
Well, I'm almost to ashamed to admit this but the second solution was right
on the money. If it wasn't for adapting the back-up script instead of the
original one it would have worked the first time. Aaargh major s**wup! Sorry
for wasting your time everybody.
By the way here's the solution for anybody who's going to do a future
DejaNews search:
$gif_data = $im->gif;
open (FILE,">test.gif") || die;
binmode FILE;
print FILE $gif_data;
close FILE;
Meint
--
"Where shall I begin? Begin at the beginning and then proceed to the end"
Alice in Wonderland - Lewis Carroll
------------------------------
Date: 1 Nov 1998 18:24:02 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Searching with perl
Message-Id: <71i902$36i$1@gellyfish.btinternet.com>
On Sat, 31 Oct 1998 22:06:34 -0000 Allan Hicks <hicks@lineone.net> wrote:
> I hope you guys (and girls?) can help me...
>
> I am reading 'Learning Perl' as I am a total beginner to programming in
> general, and have got to chapter 6 or 7 (can't really remember). What I
> want to do is create some sort of basic search engine for a web site, that I
> can improve as I get better at programming. I'm not asking for people to
> write me a load of code, just point me in the right direction or politely
> tell me that I should go back and read a lot more of the book before
> venturing in this direction again.
>
For what its worth I'd finish reading the book and maybe start reading it
once again before even considering starting on something like this.
This newsgroup is also a wonderful resource - go out and search the hell
out of it on DejaNews.
> My ideal finished article would be able to search a database (in ANY format
> as I don't have it yet) and that is easily customised so that I could apply
> it to different sites. I would like to be able to search for 'X and Y' and
> return multiple responses.
>
You will need to break this down into its constituent elements before you
can begin on its design.
The first element will generally be a program to create a predefined index
of your pages - its implementation will vary greatly on a number of factors
such as whether you only want to search your local filesystem or other
HTTP servers and how you are going to store your index which could range
from a flat text file to an SQL database. You will also need to consider
*what* you are going to index - perhaps just keywords or the full text of
your documents for instance. You may need to consider whether you are
going to need to parse your HTML documents to extract information from
META tags and so on and so forth.
The design of the search program will be heavily influenced by the decisions
you have made in the previous stage.
Anyhow, I'd recommend you as a novice programmer to begin with something a
little simpler in design and the important thing here is design which in
general should be considered before any details of implementation are
touched upon. You could for instance start with a (perhaps cliche'd)
phonebook which contains some elements that you might find in a simple
search engine. It would probably also behove you well to stay from the CGI
until such time as you are familiar with the fundamentals of program design
and development as it will add a layer of complication to the learning
process which will hinder you until you are confident in your programming
skills. Perl is far more than a language for doing CGI with as a little
time reading this newsgroup will indicate.
Good luck
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sun, 1 Nov 1998 16:28:41 -0500
From: "Pap" <Pap22@erols.com>
Subject: Re: Searching with perl
Message-Id: <71ik1f$kto$1@autumn.news.rcn.net>
The site that I (mainly) used to do the database on my site was
http://lightsphere.com/dev/class/ its really good. This will give you an
example of a database, and the simple searching page will show you how to
read the data. If you goto this page I made,
http://d2defiance.virtualave.net you will find that anything the user
submitted when they joined can be displayed by clicking their name on the
scoreboard. Pardon the scoreboard, as I am working on making it better
looking, including a question I am about to post. Hope that helped.
------------------------------
Date: Sun, 01 Nov 1998 09:48:07 -0500
From: Bob Proctor <rproctor@together.net>
To: Jeff Kiser <jeffk@synplicity.com>
Subject: Re: system statistics from Perl
Message-Id: <363C74A7.5D02C17C@together.net>
Jeff Kiser wrote:
> I was curious if there is a way (either with the standard distribution
> or via modules on CPAN) that anyone knows to obtain system statistics
> such as CPU utililization, available memory, etc. in a perl script.
> Thanks
>
> Jeff Kiser
> jeffk@synplicity.com
You will find an article titled "Benchmarking", by Brian D Foy, in the
latest copy of TPJ. He shows how to use the Benchmark module (included in
standard distribution) to get stats on CPU usage.
I had the same question regarding available memory and memory
utilization. Brian told me that he wasn't aware of any work in this area.
I'm still looking for that because we push lots of data and machines I'm
using have limited (2GB) real memory.
Bob
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
|Bob Proctor (Bob-VT-) rproctor@together.net |
| http://together.net/~rproctor/ |
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+
------------------------------
Date: Sun, 01 Nov 1998 11:25:35 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: What is the "correct" location of perl under Solaris?
Message-Id: <363C8B7C.A1BDD499@email.sps.mot.com>
Tk Soh wrote:
>
> vertreko@my-dejanews.com wrote:
> >
> > Hi All. I've got a pseudo-philosophical question for you. My company was
> > recently acquired by a bigger company. Before the acquisition, we had the
> > location of our 'perl' as /usr/local/bin/perl, and all our scripts started
> > with:
> >
> > #!/usr/local/bin/perl
> >
> > The company that bought us has their Solaris perl located at:
> >
> > #!/opt/local/bin/perl
> >
> > One of us is going to have to change, and either way, it will be a major pain
> > in the a@#. I think the version that is least prevalent in common practice
> > should be the one to change. So, I'm asking, "Which version is more common?"
>
> This is my own solution: create a symlink to Perl in the directory when I
> store my perl scripts, then use #!perl in the first line of the scripts. Not
^^^^^^
Correction. I meant #!/my_perl_directory/perl
It always happen when I type too fast and too much.
-tk
------------------------------
Date: 01 Nov 1998 12:37:00 -500
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: What is the "correct" location of perl under Solaris?
Message-Id: <ltlnlvl3gj.fsf@asfast.com>
Tk Soh <r28629@email.sps.mot.com> writes:
> vertreko@my-dejanews.com wrote:
> >
> > Hi All. I've got a pseudo-philosophical question for you. My
> > company was recently acquired by a bigger company. Before the
> > acquisition, we had the location of our 'perl' as /usr/local/bin/perl,
> > and all our scripts started
> > with:
> >
> > #!/usr/local/bin/perl
> >
> > The company that bought us has their Solaris perl located at:
> >
> > #!/opt/local/bin/perl
> >
> > One of us is going to have to change, and either way, it will be a
> > major pain in the a@#. I think the version that is least prevalent
> > in common practice should be the one to change. So, I'm asking,
> > "Which version is more common?"
I believe that /usr/local is much more common among the various unixes
out there than anything the /opt hierarchy, which I have only
encountered in Solaris. Furthermore, I have also seen /usr/local
partitions in use under Solaris, in addition to /opt.
This needn't be a huge pain ... during the conversion process, you can
just make a symlink from /opt/local/bin/perl to /usr/local/bin/perl.
> This is my own solution: create a symlink to Perl in the directory
> when I store my perl scripts, then use #!perl in the first line of
> the scripts. Not the best solution I know, but as least better than
> changing the scripts the next time Perl moves again.
>
> It would have been nice if I could creat the symlink in /usr/bin/,
> etc, but I have to do this because I'm don't have the privilege to
> create the symlink the system directories.
>
> I wonder why we couldn't just let the #! look for Perl by just PATH
> variable.
That would be wonderful ... I and others have wished for something like
this for a long time. It's not likely to happen any time soon, however,
since #! processing takes place within the operating system kernel.
Another solution besides your symlink method is to use /bin/env (or
/usr/bin/env), as follows:
#!/bin/env perl
This causes a PATH lookup for the perl executable. However, this
doesn't allow the use of command-line parameters under most operating
systems. In other words,
#!/bin/env perl -w
will not work.
--
Lloyd Zusman
ljz@asfast.com
------------------------------
Date: Sun, 01 Nov 1998 18:10:08 GMT
From: jhardy@cins.com (John Hardy)
Subject: Re: What's with these Curly brackets???
Message-Id: <4u1%1.469$%W.120592@198.235.216.4>
Thanks for all the help guy's. It turned out to be the Editor, which is strange
because I have always used Ultra Edit and never had that problem before.
I cut and paste the script into a new window and restarted UEdit and
the script worked perfectly.
I'm downloading XEmacs 20.4 now to try it out.
Thanks again
John
In article <71fkgm$lm8$1@nnrp1.dejanews.com>, jhardy3747@my-dejanews.com
says...
>
>Whats the rules with the curly brackets. If I leave the sub below as is it
>complains of syntax error at the last bracket. If I take it out it complains
>that it is missing??
>
>
>
>
>
>sub SQL_ProcedureINS
>{
>
>use OLE;
>
>$Conn = CreateObject OLE "ADODB.Connection";
>$Conn->Open("DSN=iHRS;UID=sa;PWD=");
>$RS = $Conn->Execute ("dbo.CandidateINS \@RCODE='HeyGood', \@RNAME='Smarty'");
>if(!$RS) {
> $Errors = $Conn->Errors();
> print "Errors:\n";
>}
> foreach $error (keys %$Errors) {
> print $error->{Description},"\n";
> }
> die;
>
>
>
>$RS->Close;
>$Conn->Close;
>}
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 4124
**************************************