[7183] in Perl-Users-Digest
Perl-Users Digest, Issue: 811 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 4 02:17:34 1997
Date: Sun, 3 Aug 97 23:01:44 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 3 Aug 1997 Volume: 8 Number: 811
Today's topics:
make test fails io_sock.t on HPUX 10 (Zebulon T. Bufus)
Re: Member function question. (Thomas Wernitz)
Re: Namespace warning in Perl5.004_01 <rootbeer@teleport.com>
Re: Newbie: Uninitialized Value Warning <rootbeer@teleport.com>
Re: Newbie: Uninitialized Value Warning (Keith Burdis )
Re: Oraperl and WinNT <rothd@roth.netX>
Perl and IRC <serginho@mail.serve.com>
perl help! <cascioli@geocities.com>
Re: perl help! (Anthony Mulligan)
perl install (Suzan)
Re: perl install <rootbeer@teleport.com>
Re: Perl Interface to /etc/passwd (Matthew Burnham)
perl libraries (Suzan)
Perl Resource Kit: What the hell's O'Reilly talking abo <mschilli@mission.base.com>
perl-help me again pls <cascioli@geocities.com>
PERL-WIN32 question <huntsman@micron.net>
Re: PerlIS.dll problem or something? <nick@alekto.com>
Re: Please comment: perl (NNTP) gateway (Matthew Burnham)
Printing to absolute screen position <NOSPAMadam@funnel.demon.co.uk>
Re: Ques. about parameters / initializing / my (M.J.T. Guy)
Re: Ques. about parameters / initializing / my (Tad McClellan)
Re: Ques. about parameters / initializing / my (M.J.T. Guy)
Re: Recursion problems with while and foreach (Thomas Wernitz)
Re: reducing CPU strain (HELP) <rootbeer@teleport.com>
Re: s/^\s+|\s+$//g; not working correctly on Win32? (Tad McClellan)
Re: Saving/restoring HASHes (Andrew M. Langmead)
Re: Scalar holding the name of a subroutine: calling i f_green@sirius.com
Re: Scalar holding the name of a subroutine: calling it (Andrew M. Langmead)
Re: send mail from perl <mattrope@mdhost.cse.tek.com>
Re: setuid perl scripts on HP-UX 10.20 <rootbeer@teleport.com>
Using JAVA with Perl <flash16@lightspeed.net>
Re: while (<FILE>) clobbers previous value of $_ <sfairey@adc.metrica.co.uk>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 03 Aug 1997 20:45:51 GMT
From: beacon@nr.infi.net (Zebulon T. Bufus)
Subject: make test fails io_sock.t on HPUX 10
Message-Id: <33e4eb8b.20405130@news.nr.infi.net>
I am trying to install PERL5.004 on HPUX10 and cannot get make test
past this point:
lib/io_sock.........Connection refused at lib/io_sock.t line 55.
this is the part that fails:
elsif(defined $pid) {
$sock = IO::Socket::INET->new(PeerPort => $port,
Proto => 'tcp',
PeerAddr => 'localhost'
) or die "$!";
$sock->autoflush(1);
io_sock.t seems to make it past the part where it creates the socket.
I can do make minitest just fine, and all other make test parts seem
to go OK, I have tried to skip the Socket extension using :
sh Configure -Ud_socket
but make keeps right on making Socket and make test keeps right on
testing it and hanging.
I would be happy to just get PERL installed without Socket and just
put Socket in later once I figure out what is worng.
Also, if you successfully do make minitest, and then do make install
is this miniperl that you have installed ?
------------------------------
Date: 1 Aug 1997 03:59:21 GMT
From: thomas_wernitz@tait.co.nz (Thomas Wernitz)
Subject: Re: Member function question.
Message-Id: <5rrmup$1fq@gatekeeper.tait.co.nz>
In article <5rr44j$rb1@srvr1.engin.umich.edu>,
stryker@defcon.engin.umich.edu (Benjamin T Grover) wrote:
>sub Add_Signal
>{
> my($class,$currSignal) = @_;
> $class->{$currSignal} = new Signal();
>}
>
>How do I get the $currSignal back when I want to print them out?
Shouldn't
print keys %{$class};
do the trick!
HTH,
Thomas
------------------------------
Date: Sat, 2 Aug 1997 09:51:01 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Thomas Wernitz <thomas_wernitz@tait.co.nz>
Subject: Re: Namespace warning in Perl5.004_01
Message-Id: <Pine.GSO.3.96.970802094600.26291I-100000@kelly.teleport.com>
On 30 Jul 1997, Thomas Wernitz wrote:
> >> "my" variable $PACK_NAME masks earlier declaration in same scope at
> >> twarning.pl line 7.
> I got the same warning but I got it of it by putting every package in a
> different file and creating one module which loads them all. Am I just
> preventing the warning here or do I really solve the problem?
If I understand you correctly, you have solved the problem. (Although
there may have been an easier way. :-)
That warning tells you when you (usually accidentally) try to declare the
same my() variable twice in the same scope. The scope of a my variable is
the enclosing block or file. So, by putting each one in its own file,
you've made each one different.
The "easier way" I alluded to would be to either change the name of one of
the variables, or to make new scopes for one or both of them. But in your
case, if the code works, you have no reason to worry about it.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 3 Aug 1997 09:38:41 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Joseph Gale Follansbee <follansb@seanet.com>
Subject: Re: Newbie: Uninitialized Value Warning
Message-Id: <Pine.GSO.3.96.970803093336.7094U-100000@kelly.teleport.com>
On Sun, 3 Aug 1997, Joseph Gale Follansbee wrote:
> I get "Use of intialized value at chap10.pl line 22, <STDIN> line
> 1."
> # Get the input
> &GetInput;
> # Input subroutine, with a way to Quit
> sub GetInput {
> my($counter) = 0;
> while($numbers[$counter] ne 'Q') {
You're accessing $numbers[0], but you haven't put anything into it before
this. That looks like the uninitialized value to me. But since I didn't
count the lines, I'm not sure whether that's line 22.
You may want some code somewhat like this. (Then again, you may need to
take another look at your program's internal logic.)
while (
defined($numbers[$counter]) and
$numbers[$counter] ne 'Q'
) { ... }
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 3 Aug 1997 18:37:26 GMT
From: keith@rucus.ru.ac.za (Keith Burdis )
Subject: Re: Newbie: Uninitialized Value Warning
Message-Id: <5s2j56$gum@quagga.ru.ac.za>
Joseph Gale Follansbee (follansb@seanet.com) wrote:
: Hello,
: I'm just learning Perl as my first language and I'm getting a warning I
: can't seem to eliminate. After running the program below and entering
: data, I get "Use of intialized value at chap10.pl line 22, <STDIN> line
: 1." Then, every time I enter data, I get the same message, only it says
: line 2, line 3 and so on. I've tried every thing I can think of to
: initialize the values pointed toward, with no luck. The final output of
: the program seems unaffected. Any ideas?
: Here's the code (Don't laugh too hard!):
: #! usr/bin/perl -w
The -w is what is generating the warnings. Larry will be proud that you're
using it :-)
: # A program to help me learn about subroutines (chap10.pl)
: # This program adds all the elements in an array for a total.
: # Get the input
: &GetInput;
: # Do the calculation
: &Calculate(@numbers);
: # Input subroutine, with a way to Quit
: sub GetInput {
: my($counter) = 0;
: while($numbers[$counter] ne 'Q') {
$numbers[$counter] has never been assign anything when the above check is
made. The first time $numbers[0] has not been assigned any value, so a
warning is generated. Then the first number is entered and stored in
$numbers[0]. $counter is incremented by 1 and then the check is on
$numbers[1] which has also never been assigned a value, and so on.
Here's a possible replacment for that line:
$numbers[$counter] = '';
while($numbers[$counter-1] ne 'Q') {
: print "Enter a number. Press Q to quit.\n";
: $numbers[$counter] = <STDIN>;
: chomp($numbers[$counter]);
: if ($numbers[$counter] eq 'q') { ($numbers[$counter] =~ tr/q/Q/) };
: if ($numbers[$counter] eq 'Q') { last };
: $counter++;
: }
: return(@numbers);
: }
: # Calculation subroutine
: sub Calculate {
: pop(@numbers); # Remove the "Q"
: print "The elements in \@numbers are @numbers.\n"; # List the
: elements.
: my($counter) = scalar(@numbers); # Get the number of elements
: while($counter > 0) {
: $element = pop(@numbers);
: $answer += $element;
The first time the above assignment is made $answer has no value. You need to
initialise it to zero before the while loop.
: $counter--;
: }
: return($answer);
: }
: print "Addition of the elements in \@numbers is $answer.\n";
Hope this helps. You'll be JAPH soon :-)
- Keith
--
Keith Burdis - BSc Honours (Com Sci) - Rhodes University
Email : keith@rucus.ru.ac.za
WWW : http://www.rucus.ru.ac.za/~keith/
IRC : Panthras JAPH
Standard disclaimer.
---
------------------------------
Date: 2 Aug 1997 22:16:03 GMT
From: "Dave Roth" <rothd@roth.netX>
Subject: Re: Oraperl and WinNT
Message-Id: <01bc9f91$aef3d160$11906ec6@main2>
You could use Win32::ODBC. All you need to do is install the Oracle ODBC
driver (there are several of them around) then write your script.
dave
--
================================================================
Dave Roth ...glittering prizes and
Roth Consulting endless compromises, shatter
rothd@roth.net the illusion of integrity
My email address is disguised to fool automailers. Remove the
trailing 'X' to send me email.
****************************************************************
Use of this message or email address for commercial purposes
(including "junk" mailings) is strictly prohibited and protected
under current international copyright laws and United States
Code, Title 47, Chapter 5, Subchapter II.
Jamie Kinney <jkinney@us.oracle.com> wrote in article
<33D39060.2164ADB@us.oracle.com>...
> Does the installation of Oraperl or DBD/DBI for Perl 5.004 require
> Microsoft Visual C++ for compilation? I have Borland C++ Dev Suite (v
> 5.0) and have had no luck installing DBD or DBI. Could anyone give me
> some helpful advice on accessing an Oracle Database via Perl?
>
> Thanks in advance,
>
> Jamie Kinney
>
>
------------------------------
Date: Sun, 03 Aug 1997 13:13:56 -0300
From: Sergio Stateri Jr <serginho@mail.serve.com>
Subject: Perl and IRC
Message-Id: <33E4AE44.1F00A2B7@mail.serve.com>
Hi ! Does Perl under Win32 work with Net::IRC ? Where do I find this
module ?
thanks
--
--------------------------------------
Sergio Stateri Jr
Sao Paulo (SP) Brasil
e-mail : serginho@mail.serve.com
--------------------------------------
------------------------------
Date: Sat, 02 Aug 1997 21:54:50 +0200
From: ".70 Andreas 07." <cascioli@geocities.com>
Subject: perl help!
Message-Id: <33E39089.E6FD531B@geocities.com>
I need some help, I am not very good at perl, but I'd like my script to
pop up a javascript alert like this or something:
print "<!--\n";
print "alert('Hello world')\n";
print "// -->\n";
I can't get it to work, I know I can't use the two ' on line 3, but I
have no clue of what more there is to correct.
Could anyone please help?
Andreas
------------------------------
Date: 3 Aug 1997 05:07:13 GMT
From: avm@best.com (Anthony Mulligan)
Subject: Re: perl help!
Message-Id: <avm-2808560435200001@avm.vip.best.com>
I think you need to add backslash escapes to the \n;
# print "<!--\\n";
It's the first thing I would try anyway...
In article <33E39089.E6FD531B@geocities.com>, ".70 Andreas 07."
<cascioli@geocities.com> wrote:
# I need some help, I am not very good at perl, but I'd like my script to
# pop up a javascript alert like this or something:
#
# print "<!--\n";
# print "alert('Hello world')\n";
# print "// -->\n";
#
# I can't get it to work, I know I can't use the two ' on line 3, but I
# have no clue of what more there is to correct.
# Could anyone please help?
#
# Andreas
------------------------------
Date: Sun, 03 Aug 1997 20:59:06 GMT
From: yquem@hotmail.com (Suzan)
Subject: perl install
Message-Id: <33e4f067.51064733@news.hol.fr>
I want to install perl on my system (win95). I downloaded the latest
release (perl5.004_01 from perl.com) and extracted the tar file.
ok for that.
what should I do now?
Thank you
------------------------------
Date: Sun, 3 Aug 1997 18:06:39 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Suzan <yquem@hotmail.com>
Subject: Re: perl install
Message-Id: <Pine.GSO.3.96.970803180550.12522B-100000@linda.teleport.com>
On Sun, 3 Aug 1997, Suzan wrote:
> I want to install perl on my system (win95). I downloaded the latest
> release (perl5.004_01 from perl.com) and extracted the tar file.
> ok for that.
> what should I do now?
If there aren't any installation notes or readme files to be found in what
you've downloaded, you should write a note to the archive maintainer and
ask that he or she get them for you. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 03 Aug 1997 14:30:48 GMT
From: danew@enterprise.net (Matthew Burnham)
Subject: Re: Perl Interface to /etc/passwd
Message-Id: <33e56348.842862@news.enterprise.net>
fozz@cray.com (Doran Barton) wrote:
[snip]
>Assuming you have crypt support, all you will need to do is utilize this
>Perl functions:
[snip]
>sub crypt_passwd {
> local($passwd) = @_;
> local($salt);
>
> srand(time());
> $salt = &to64(rand(32767),2);
>
> return(crypt($passwd,$salt));
>}
Since you know about using crypt properly, I can't get it to work
properly in a .htpasswd file.
Does it matter what salt I use?
ie. can I do crypt($passwd, 'aa');?
or can I do crypt($passwd, 'bb');
and either one will work when htaccess validates the password?
I can't see how it will manage to do this, since it would have to go up
to at least (depending on how many different characters are valid) 26^2
crypts to check for all the valid two-letter salts, etc.
Or, since I can't get htpasswd to work properly when I use perl's crypt
function, has a particular salt got to be used?
Will crypt yield the same results across platforms? ie. will I get the
same crypt from the same salt on my own win95 system as on a FreeBSD
system.
TIA
--
Matthew Burnham, Manager, MindWeb | danew@enterprise.net
Commercial web design and hosting, reasonable rates
UKP24/Mb/Year for DIY space | mindweb@pobox.co.uk
FTP, CGI, password protection, etc. too!
http://www.mindweb.co.uk/
------------------------------
Date: Sat, 02 Aug 1997 22:15:47 GMT
From: yquem@hotmail.com (Suzan)
Subject: perl libraries
Message-Id: <33e3b05e.56381047@news.hol.fr>
I am novice with perl. I got a cgi script and wanted to test it on my
system. Nothing happens. I presume I have not the required libraries.
How is it possible to get them?
My system: win 95.
Thank you for your answer.
------------------------------
Date: Sun, 03 Aug 1997 13:55:17 -0700
From: Michael Schilli <mschilli@mission.base.com>
Subject: Perl Resource Kit: What the hell's O'Reilly talking about??
Message-Id: <33E4F035.5A7F67E7@mission.base.com>
Hi folks,
have you seen the newest announcement from O'Reilly? According to
http://www.oreilly.com/catalog/prkunix/desc.html
a "Perl Resource Kit" will be available in Fall 97. What? Here's the
description:
Software tools on the Kit's CD include:
* A Java-enhanced Perl compiler, written by Larry Wall, creator
of Perl
...
Is this a joke or what?
-- Michael
----------------------------------------------------------
Michael Schilli http://mission.base.com/mschilli
----------------------------------------------------------
------------------------------
Date: Sun, 03 Aug 1997 21:44:51 +0200
From: ".70 Andreas 07." <cascioli@geocities.com>
Subject: perl-help me again pls
Message-Id: <33E4DFB3.93B0FC27@geocities.com>
Thanks for the hint, I got it to work now, but the cgi script opens this
alert in a new blank html page.
Does anyone know how to make it execute in the same html page?
print "Content-type: text/html\n\n";
print "<script>\n";
print "<!--\n";
print "alert('Hello\\nWorld!')\n";
print "// -->\n";
print "</script>\n";
Andreas
------------------------------
Date: 2 Aug 1997 17:55:42 GMT
From: "Robert A. Huntsman" <huntsman@micron.net>
Subject: PERL-WIN32 question
Message-Id: <01bc9f6b$c6d07ac0$1bd586cc@home>
I've brought up perl in a nT 4.0 server. I have several working LINUX
scripts that use socket calls. Under NT all of my "connects" fail. I
located an SMTP mail script written for NT 4.0 and PErl-Win32, and it also
fails during the connect.
Question #1: Is there some basis fundamental thing I am missing herE?
Question #2: Where is the proper news group for PERl-WIN32
installation/scripting questions?
I thank you in advance for any assistance or pointers to assistance. (I am
rummaging through all the FAQ's I can find). e-mail copies of response to
bobh@qq.com are also appreciated.
bobh@qq.com
------------------------------
Date: Fri, 01 Aug 1997 12:57:03 +0300
From: Nick Ioffe <nick@alekto.com>
Subject: Re: PerlIS.dll problem or something?
Message-Id: <33E1B2EF.49B144F6@alekto.com>
Well, it is me again...
I changed definitions to run perl cgi scripts with perl.exe, not
perlis.dll.
Since then everything works fine so I conclude IT IS PERLIS.DLL problem
(or problem of PERLIS.DLL tcp-communication).
Do you, gurus, have any idea of solving the problem with PerlIS.dll,
since
I still prefer to run ISAPI scripts on NT
Sincerely,
Nick....
------------------------------
Date: Sun, 03 Aug 1997 14:30:56 GMT
From: danew@enterprise.net (Matthew Burnham)
Subject: Re: Please comment: perl (NNTP) gateway
Message-Id: <33e6658a.1421027@news.enterprise.net>
Marcel Turcotte <M.Turcotte@icrf.icnet.uk> wrote:
>I wrote the following piece of code, it acts as a software gateway,
>providing access to a machine (A), by the mean of an intermediate
>machine (B), to a third machine (C) that would not normally have
>direct access to machine (A). For example, someone would use it to
>read his/here news from a host not served by the NNTP host.
>
>This is the first time I write something like this
>(perl/socket/client/server) and I am seeking comments:
>
>- Are there any pieces of code doing that job already?
NNTPClient on CPAN.
DejaNews if you have web access from A
Reference.com if you have web access from A
Mail2News gateways if you have email access from A
>- Would it be useful to make it clean and robust? Would you use it?
I wouldn't mind a copy, I could do with a news link from a
>- It's creating zombies, what's wrong?
Dunno without the code (and possibly not then).
>- It's not always writting to the log file, why?
Dunno without the code (and possibly not then).
--
Matthew Burnham, Manager, MindWeb | danew@enterprise.net
Commercial web design and hosting, reasonable rates
UKP24/Mb/Year for DIY space | mindweb@pobox.co.uk
FTP, CGI, password protection, etc. too!
http://www.mindweb.co.uk/
------------------------------
Date: Sat, 02 Aug 1997 21:29:40 +0100
From: Adam Naylor <NOSPAMadam@funnel.demon.co.uk>
Subject: Printing to absolute screen position
Message-Id: <33E398B4.2E17E7F6@funnel.demon.co.uk>
Hi gurus,
I need to print to an absolute screen position from perl, so that I can
update that same line with new information.
Example:
12 of 100
13 of 100
14 of 100
.......but preferably overwriting the earlier print without calling
'clear'.
I realise this is probably dead simple but I can't find it anywhere in
the man pages!
Thanks in advance for any help,
Adam Naylor
mailto:root@funnel.demon.co.uk
--
Health is the slowest possible rate at which one can die.
Remove 'NOSPAM' from my address to reply.
------------------------------
Date: 2 Aug 1997 21:06:18 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Ques. about parameters / initializing / my
Message-Id: <5s07ga$ndf@lyra.csx.cam.ac.uk>
In article <5ru6cp$1fn$2@news2.voicenet.com>, <nospam@domain.com> wrote:
>
>Let's say I have a function like this:
>
>sub dostuff {
> my ($this,$that) = @_; # line 1
>
> print "Gotta do $this.\n"; # line 2
> print "Gotta do $that.\n"; # line 3
>}
>
>And let's say that it's possible that somewhere, this
>function might be called with only one parameter,
>like so:
>
>&dostuff("washing");
>
>This generates a warning, since we're using an
>uninitialized variable.
It's worth pointing out that it isn't the "my" line which provokes
the warning, but the subsequent use of $that.
And a convenient paragigm for providing defaults for undefined variables is
my ($this,$that) = @_;
$this = 'default for this' unless defined $this;
$that = 'default for that' unless defined $that;
Mike Guy
------------------------------
Date: Sat, 2 Aug 1997 08:16:38 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Ques. about parameters / initializing / my
Message-Id: <mvbvr5.qp.ln@localhost>
nospam@domain.com wrote:
: Let's say I have a function like this:
: sub dostuff {
: my ($this,$that) = @_; # line 1
: print "Gotta do $this.\n"; # line 2
: print "Gotta do $that.\n"; # line 3
: }
: And let's say that it's possible that somewhere, this
: function might be called with only one parameter,
: like so:
: &dostuff("washing");
: This generates a warning, since we're using an
: uninitialized variable.
: So here's the question: is there any nice, elegant way
: to rewrite line 1, which will initialize the variables
: to empty strings and eliminate the warning, but which still
: is nice, short and sweet?
Subject to your interpretation of 'nice', 'short', 'sweet', and 'elegant',
you might like:
sub dostuff {
my $this = shift || '';
my $that = shift || '';
...
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 3 Aug 1997 10:55:59 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Ques. about parameters / initializing / my
Message-Id: <5s1o3v$mic@lyra.csx.cam.ac.uk>
In article <mvbvr5.qp.ln@localhost>, Tad McClellan <tadmc@flash.net> wrote:
>
>Subject to your interpretation of 'nice', 'short', 'sweet', and 'elegant',
>you might like:
>
>sub dostuff {
> my $this = shift || '';
> my $that = shift || '';
> ...
You really shouldn't post that without the traditional caveat:
"But that probably won't do what you want if the argument happens to be 0.
To get that case right, you have to do a boring old defined."
Mike Guy
------------------------------
Date: 1 Aug 1997 02:47:13 GMT
From: thomas_wernitz@tait.co.nz (Thomas Wernitz)
Subject: Re: Recursion problems with while and foreach
Message-Id: <5rrinh$15v@gatekeeper.tait.co.nz>
In article <33e1168d.198715626@news.internetmci.com>,
jason@cimedia.com (Jason Bodnar) wrote:
>So, I looked at some old code I wrote a while back that head messed
>with this file structure before and for some reason it used foreach()
>instead of while() in the sub. So I changed my code to look like this:
>
>sub recurse {
> my $file = shift;
> open FILE, $file;
> foreach (<FILE>) {
> recurse($_);
> } # End while
> close FILE;
>} # End recurse()
Hi,
the reason is simple: a while loop reads the handle in scalar context, means
only one line at a time. Since you open a new file with the same handle
everytime you call recurse, you close the one opened before. If you get back
from recurse and try to read another line ... aetsch ... the file is closed.
This little program is bad coding BTW. You don't check if open is successful!
You can get it working with "while" if you use IO:Handle or FileHandle instead
of the plain handle.
Now if you use foreach it read the handle in list context, means everything in
one slurp. Voila, you don't care if the file is closed afterwards!
HTH,
Thomas
------------------------------
Date: Sun, 3 Aug 1997 08:54:42 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ryan <rmcguigan@ramresearch.com>
Subject: Re: reducing CPU strain (HELP)
Message-Id: <Pine.GSO.3.96.970803084723.7094K-100000@kelly.teleport.com>
On 2 Aug 1997, Ryan wrote:
> I have written a script that opens every file in our website one by one
> (over 6,000 files) and parses all the links and image tags, then it
> verifies the existence of each one. I'm not highly experienced, but I
> did get the script to work extremely well.....BUT, after a while it
> starts to put too much of a strain on the cpu (PPro200) and it cannot
> verify the links because the server comes to a crawl and the checker
> times out(or so I assume, I use the libwww-perl5 module for link
> checking).
Are you forking new processes? If you're running an increasing number of
processes, that could cause the system load you describe. Otherwise,
unless you're storing a lot of information in memory, the system load
should remain roughly constant. (The script (but not the server) may "come
to a crawl" when it reaches a number of bad links, though.)
> First question, when I declare "local @URLS" in a sub routine, when it
> exits that sub, does it get destroyed?, or does it still take up memory?,
Perl usually recycles the memory internally, but can't "give it back" to
the system. So, the next time you need some memory, Perl should get it
from the freed memory pool. (But you should probably use my() in place of
local(). It's faster, among other gains.)
> (memory doesn't seem to be the problem though, it never uses more than 6
> megs (our machine has 128))
What do you see taking up time and memory when your system is slowed? (A
utility like top(1) can be helpful.)
> and second, how can I decrease the CPU usage?
You can 'nice' the program, either with nice(1) or with something like
this near the start.
# Let's be nice, since this may take a while.
setpriority 0, 0, getpriority(0,0) + 9;
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 1 Aug 1997 15:44:08 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: s/^\s+|\s+$//g; not working correctly on Win32?
Message-Id: <oqhtr5.vg4.ln@localhost>
Thomas Winzig (tsw@pvo.com) wrote:
: Tad McClellan wrote:
: >
: > Thomas Winzig (tsw@pvo.com) wrote:
: > : Hello,
: >
: > : I am running Win32 Perl 5.003_07 (build 306) on NT4 server.
: >
: > : While parsing through a ton of email messages, I am trying to
: > : strip whitespace from the beginning and end of the message, like so:
: >
: > : $msg =~ s/^\s+|\s+$//g;
: >
: > : The problem is, it seems to also be stripping "doubled up newlines" at
: > : the same time, even the ones INSIDE the string (please bear with me,
: > : here).
: >
: > : Since I am not using the 'm' for multiline matching, I would expect the
: > : pattern above to only remove the whitespace from the beginning and
: > : ending of my message (the string contained within $msg). That is not the
: > : case!
: >
: > I would expect that too. Hmmm...
: <SNIP>
: > I tried it under Linux with both 5.003 and 5.004.
: >
: > Got the same results that you do.
: >
: > Looks like a bug to me...
: Hello,
: Thanks for the reply. Are you saying that Linux perl also suffers
: from this bug as well? I don't have my SGI handy, so I can't test
: perl on there, but I wonder if this is a bug in regular perl or
: just win32 perl?
Yes. It appears to be in regular perl.
That's why I included the script and output that I ran under Linux w/5.003.
: Tom Pheonix also responded to me via email asking me to submit it as
: a bug to the Win32 perl porting team, which is what I will do right now.
It seems to be bigger than just the Windoze port...
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Sat, 2 Aug 1997 15:51:15 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Saving/restoring HASHes
Message-Id: <EEAMpF.GBr@world.std.com>
"Daniel J. Wandeler" <wando@miro.amd.com> writes:
>I am creating a fairly large hash, and I would like to save the state
>of to a file, so that I can open it at a later time. Ideally I would
>like to create the hash on disk rather than in memory. Are there any
>perl5 modules which handle this?
One thing to look at is the DBM modules that come with the standard
perl distribution. Check perl's documentation for AnyDBM_File.pm.
--
Andrew Langmead
------------------------------
Date: Sun, 03 Aug 1997 07:34:06 GMT
From: f_green@sirius.com
Subject: Re: Scalar holding the name of a subroutine: calling it
Message-Id: <33e4327f.5770914@news.sirius.com>
mike@stok.co.uk (Mike Stok) wrote:
>In article <33E11560.64E4@earthlink.net>,
>Doug Smaglik <dougsmaglik@earthlink.net> wrote:
>>
>>I am building a scalar variable that will hold the name of a subroutine
>>I wish to call. I would like to make the call:
>>
>>$subroutine_name $parameter
>
>You can say
>
> &$subroutine_name ($parameter);
>
>if you like, even in "old" perls. In modern perls you may have to make
>sure that strict refs aren't in effect before using it (but with modern
>perls you have real subroutine erfs, so you couyld have a hash whose keys
>are the name and whose values are references to anonymous subroutines..._.
On a related note, I have a problem in which I am trying to create a scalar
whose name is equal to the contents of another scalar. However, the code:
$foo = "bar";
$"$foo" = "This variable's name should be \$bar.";
gives me a "Scalar found where operator expected" error.
Everyone I talk to says naming a variable with the contents of another
variable should be do-able (and some go so far as to say it should even be
easy), but none of them are sure how. Any ideas?
--Kai MacTane.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GO/U d-- s+:- a- C++ UL(+)>+++>$ P+>$ E- J+>+++>$ W++>$ N+ K
w++(--)@ PS+(+++) PE Y+ t(+) 5++ R+ tv-(--) b+++(+) DI++ D+ G
e(++) h r++(+) y++(+++++)(*)
------END GEEK CODE BLOCK------
-- JaCk VoLtAgE
------------------------------
Date: Sun, 3 Aug 1997 09:54:33 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Scalar holding the name of a subroutine: calling it
Message-Id: <EEC0ux.DsM@world.std.com>
f_green@sirius.com writes:
>On a related note, I have a problem in which I am trying to create a scalar
>whose name is equal to the contents of another scalar. However, the code:
>$foo = "bar";
>$"$foo" = "This variable's name should be \$bar.";
>gives me a "Scalar found where operator expected" error.
Try
$foo = "bar";
$$foo = "This variable's name should be \$bar.";
# sometimes I right $$foo as ${$foo} for clarity
print $bar;
This is called a "symbolic reference" and if you want to read more
about them, check the perlref man page.
What is happening in yor code is that perl sees the variable $", and
then the variable $foo, with no operator between them. Its like you
said:
$foo $bar;
in your code. Perl knows what you want worked on, but not what to do
with them.
--
Andrew Langmead
------------------------------
Date: Wed, 30 Jul 1997 09:05:05 -0700
From: Matt Roper <mattrope@mdhost.cse.tek.com>
To: Murat KASIKCIOGLU <mkasikci@escortnet.com>
Subject: Re: send mail from perl
Message-Id: <Pine.SUN.3.95q.970730090155.18896X-100000@tekgp4.cse.tek.com>
Try this subroutine:
sub email
{
$MAILER = "/usr/lib/sendmail -t"; ### Replace with correct path
my ($TO,$FROM,$SUBJECT,$BODY) = @_;
my $ANS=0;
if (-e (split(/\s+/,$MAILER))[0]) { ##### does mailer exist?
$TO =~ s/\s+$//; ##### kill whitespace at end
$FROM =~ s/\s+$//;
$SUBJECT =~ s/\s+$//;
$ANS=open(MAIL,"|$MAILER");
print MAIL "To: $TO\nFrom: $FROM\nSubject: $SUBJECT\n\n$BODY";
close MAIL;
}
$ANS; ##### return value is if pipe was opened or not
}
On Wed, 30 Jul 1997, Murat KASIKCIOGLU wrote:
> Hi,
>
> How can I send e-mail from perl program. ?
>
> Thanks.
>
> Murat.
> mkasikci@escortnet.com
> www.insaat.net
>
>
> Ps. I'm using SCO UNIX SYSTEM 5 and have tried to make with MAIL::SEND.PM,
> but didn't work.
>
>
>
>
>
>
==============
Matt Roper
mattrope@mdhost.cse.tek.com
------------------------------
Date: Wed, 30 Jul 1997 09:30:38 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Sebastian Meyer <meyer@megatel.de>
Subject: Re: setuid perl scripts on HP-UX 10.20
Message-Id: <Pine.GSO.3.96.970730092432.23957K-100000@kelly.teleport.com>
On 29 Jul 1997, Sebastian Meyer wrote:
> Is it possible to run perl scripts setuid on HP-UX 10.20?
> When I start a setuid perl script it just gives me:
> YOU HAVEN'T DISABLED SET-ID SCRIPTS IN THE KERNEL YET!
> FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP!
That's Perl, trying as hard as it can to keep you from shooting yourself
in the foot. It's saying that your set-id scripts seem to be set-id by the
kernel in an insecure manner. :-P
> When I put up the question, howto disable set-id scripts, in
> comp.sys.hp.hpux I received this one answer:
>
> > That is not a feature of hp-ux. however, you can put the script in,
> > saay, /usr/local/bin and make this a separate file system with
> > "nosuid" set in /etc/fstab.
That's one way to do things. If you're a sysadmin, you'll also want to
ensure that none of your users falls into the trap of making a script
set-id, because to do so seems to be a security hole. (I'd send a
nastygram to my vendor, if I found that this was the case.)
In the end, though, you still want to run a Perl script set-id. Here's
what perldiag says about that message:
=item YOU HAVEN'T DISABLED SET-ID SCRIPTS IN THE KERNEL YET!
(F) And you probably never will, because you probably don't have the
sources to your kernel, and your vendor probably doesn't give a rip
about what you want. Your best bet is to use the wrapsuid script in
the eg directory to put a setuid C wrapper around your script.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 02 Aug 1997 15:55:44 -0700
From: Dan Gordon <flash16@lightspeed.net>
Subject: Using JAVA with Perl
Message-Id: <33E3BAF0.8E2E5BBB@lightspeed.net>
Here's my problem...
I have a java applet that works just fine when I call it from a static
html page; however, when I'm calling it from a perl generated html
document I'm getting the following errors: "can't find applet" and
"java.lang.ClassFormatError: Bad Magic Numbers"...
I get the "can't find applet" error the first time I try to load it and
the other error on subsequent reloads...how do I tell the browser where
the class file is? or where do I need to but the class files? in the
cgi-bin folder? or in the root folder where I'm calling the script from?
Any help would be greatly appriciated
Dan
------------------------------
Date: Wed, 30 Jul 1997 17:34:14 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: "Michael Schmahl v4.2" <fxmgs@aurora.alaska.edu>
Subject: Re: while (<FILE>) clobbers previous value of $_
Message-Id: <33DF6D05.D80C86FB@adc.metrica.co.uk>
Michael Schmahl v4.2 wrote:
> This is definitely undesirable behaviour, in my opinion.
Not in mine, considering all $_ is is another variable ( all be it a bit
of a special one ) so why would you want it to behave differently from
any other variables. I am not sure where it states it in the man pages
but it the Camel and the refence guide it does state that $_ is a global
variable and should be localised within blocks/subroutines.
> Is it a bug?
Nope, I think you are expecting too much of it, after all you can only
have one instance of a variable within any given block. How would you
access the different instances of the same variable i.e:
foreach( @data1 ) {
foreach( @data2 ) {
Now what do you do if you want the current @data1 AND @data2 entry,
they can't both be in $_.
I suggest you use the 'foreach $var ( @array )' syntax, after all its
not really any slower than using the defaults and it is probably clearer
( and safer in the long run ) if someone else has to maintain your
scripts in the future.
Simon
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 811
*************************************