[13467] in Perl-Users-Digest
Perl-Users Digest, Issue: 877 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 22 14:07:40 1999
Date: Wed, 22 Sep 1999 11:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <938023511-v9-i877@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 22 Sep 1999 Volume: 9 Number: 877
Today's topics:
Re: "Pattern matching" <aqumsieh@matrox.com>
(-d $filename) test cacook@my-deja.com
Re: ActivePerl on Windows95 HELP <camerond@mail.uca.edu>
Re: answers <tchrist@mox.perl.com>
Apache behavior (was Re: mkdir(). What am I doing wrong (Kragen Sitaker)
Arrays?!? <poohba@io.com>
automatic news poster script <info@job-base.com>
Re: automatic news poster script (Kragen Sitaker)
Re: automatic news poster script <brian@innovtech.com>
Re: batch <tech@tburg.net>
Re: batch <cassell@mail.cor.epa.gov>
Re: Case insensitive SQL query c_j_marshall@hotmail.com
Re: Checking for space <crt@kiski.net>
Copying directories and subdirectories <brian@innovtech.com>
How to extract data in 'groups' <tom.kralidis@ccrs.nrcanDOTgc.ca>
Re: memory use of children <elaine@chaos.wustl.edu>
Re: memory use of children (Bill Moseley)
Re: mkdir(). What am I doing wrong? <sephiroth@id-base.com>
Re: newbie question...well kindof <juergenp@cc.gatech.edu>
Re: newbie question...well kindof <juergenp@cc.gatech.edu>
Re: newbie question...well kindof (Kragen Sitaker)
Re: Newbie question <elaine@chaos.wustl.edu>
PERL GUI Handlers for Winblows 95/98/NT ... <genus@ems.att.com>
Re: Perl Module for MS Access? <hartleh1@westat.com>
Re: Problem with method - unblessed <aqumsieh@matrox.com>
Re: REQ: tell-a-friend script <cassell@mail.cor.epa.gov>
Slow runtime - a problem with my server? <ccwoods1@antiquebottlesdot.net>
Re: Slow runtime - a problem with my server? <elaine@chaos.wustl.edu>
Re: sort depth <rhomberg@ife.ee.ethz.ch>
System call in windows <hdeshpandeNOvrSPAM@carlson.com>
Re: target frame in URL redirection <hartleh1@westat.com>
Re: Test regex <*@qz.to>
Using the Expect.pm module w/Perl5.00502 <mark_jarvis@net.com>
Re: Win32::ODBC.pm hangs CGI.pm under Apache (Kragen Sitaker)
Re: You should be admired <jeff@vpservices.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 22 Sep 1999 12:34:47 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: "Pattern matching"
Message-Id: <x3y3dw67vmh.fsf@tigre.matrox.com>
Anil Mereddy <mereddy@idt.net> writes:
> I am attemting to write a perl program that will read one or more files
> and analyze the contents of the files.
> I was trying to find out capitalized words, puntuation marks, blank
> lines, # of sentences in the file.
What I would do (which maybe simplistic) is to read each line, split
it into an array (space delimited), and analyze each element of the
array. Dealing with sentences will be tricky, so I will assume that
any period will indicate the end of a sentence. This ofcourse is very
simplistic, and will count the occurence of things like 'Mr.' as a
sentence. But I'll let you worry about that :)
I also assume that capitalized words are words whose letters are all
capital (with maybe underscores and numbers).
my $cap_words = my $punc_marks = my $blank = my $sentences = 0;
while (<F>) {
# Check if empty line
/^\s*$/ && ++$blank && next;
# check for periods.
$sentences += tr/.//;
# check for punctuation marks (don't miss any!)
# are brackets punctuation marks? you decide.
$punc_marks += tr/;':",./?!@#$%^&*(){}~`[]//;
# check each word if capital
while (/(\S+)/g) {
my $word = $1;
$cap_words++ if $word =~ /^[A-Z_0-9]+$/;
}
}
HTH,
--Ala
------------------------------
Date: Wed, 22 Sep 1999 17:41:06 GMT
From: cacook@my-deja.com
Subject: (-d $filename) test
Message-Id: <7sb4bg$jkk$1@nnrp1.deja.com>
Greetings,
Well I have looked extensively in the Perl FAQ and
on the web, but I have not found any reason why
the following code shouldn't work right:
if (-d $file_name)
{
}
else
{
}
the problem is, that after the first
sub-directory, it goes into the else clause every
time, even if the file is a directory!
My code is attached below, the full sub it is in:
===========code snippet=================
sub rem_dir # remove a non-empty directory;
{
my ($dir_name, $file_name, @file_list ) ;
$dir_name = $_[0];
print " \n Entering rem_dir, arg =
<<$dir_name>>\n";
chdir ($dir_name);
opendir (CURRENTDIR, $dir_name);
@file_list = readdir (CURRENTDIR);
# @file_list = glob("*");
print "List of files in dir <<$dir_name>> to be
removed: <<@file_list>>\n";
foreach $file_name (@file_list)
{ if (-d $file_name) # if it is
a directory, delete it.
{ rem_dir ($file_name);
}
else
{ unlink ($file_name) || die "\nCannot
remove file <<$file_name>> in <<$dir_name>>\n";
};
};
# end of
foreach ($file_name)
print "\n*****************\n";
closedir (CURRENTDIR);
chdir("..");
print "Directory name to be removed. Should be
empty: <<$dir_name>>\n";
rmdir ($dir_name) || die "\n Cannot remove
directory <<$dir_name>>\n";
return 1;
} ; # end of rem_dir
===========end of code snippet==================
It transverses the directory tree fine, down into
the first sub-directory. But the diagnositc
writes I have in the routine show that it finds
that a second sub-directory in the same parent is
not shown as a directory! I'll need that kind of
code for other routines as well as the delete one
shown above.
If I've made a logic error and it isn't Perl,
sorry, but I sure can't find one. Please post
here if you can find why this doesn't work.
Oh and I am running ActivePerl on NT 4.0; version
5.00503 I think (should be).
Thanks all!
Frith!
C Cook
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 22 Sep 1999 11:40:18 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: ActivePerl on Windows95 HELP
Message-Id: <37E90672.EF735739@mail.uca.edu>
Daniel wrote:
>
> Hello,
>
> I just now installed ActivePerl build 519 on my Windows95 Computer. I
> wrote this file "readarticlecgi.pl":
>
> [snipped]
>
> With my Netscape Browser I loaded it with File/Open Page (Ctrl+O) and I
> just see an MS-DOS window, which shows quickly my "article1.txt" !
>
> What is wrong ? I thought see my file (article1.txt) in my Netscape
> Browser.
It depends. Is your server configured correctly to run Perl scripts and
send the output to your browser? (Note, there is a second, implied
question in this answer, probably a third, and most likely a fourth...)
Cameron
--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu
------------------------------
Date: 22 Sep 1999 11:15:56 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: answers
Message-Id: <37e90ecc@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
lr@hpl.hp.com (Larry Rosler) writes:
:Of course, that isn't definitive. Even I am using Windows NT to post
:from. But I have bought a decent newsreader.
"Buy"? Sigh.
:PoB-ness is a state of mind, not of tools.
True. Although it's kinda anti-tool, or non-tool.
--tom
--
Tip: If a customs officer asks for your visa, don't say, "I
have cash. Do you take that?"
-- DNRC Newsletter, Scott Adams
------------------------------
Date: Wed, 22 Sep 1999 17:33:51 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Apache behavior (was Re: mkdir(). What am I doing wrong?)
Message-Id: <3q8G3.3494$QJ.201784@typ11.nn.bcandid.com>
In article <37E90BA3.20ACD41E@id-base.com>,
sephiroth@id-base.com <sephiroth@id-base.com> wrote:
>Kragen Sitaker wrote:
>> which [Apache] does not behave as you
>> describe.
>
>I disagree, it does in my experience.
Apache includes a significant amount of code, and some icons, for
producing nice-looking directory listings for directories that do not
contain an index.html. Its configuration file language includes
several directives for configuring the auto-generated index, such as
IndexOptions. See http://www.apache.org/docs/mod/mod_autoindex.html
for more info.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Wed Sep 22 1999
47 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 22 Sep 1999 12:35:09 -0500
From: Poohba <poohba@io.com>
Subject: Arrays?!?
Message-Id: <Pine.LNX.4.10.9909221233090.7611-100000@fnord.io.com>
I have a data file. The first field has a number in it. When I run my
program it creates another record. I want to subtract the next to last
record first field from the last record first field. How do I do that?
* Web Page Designs *
/ poohba@io.com | www.io.com/~poohba\
---------------------------------------
\ For info about me send message with /
* subject "send file help" *
------------------------------
Date: Wed, 22 Sep 1999 18:57:36 +0200
From: Job-Base <info@job-base.com>
Subject: automatic news poster script
Message-Id: <37E90A80.F546F696@job-base.com>
Could someone tell me if it is possible to include some part of perl
code with which it would be able to directly send a message to a usenet
server. I would like to have the perl script send the data
automatically without user intervention. But how to do that
TIA
Michael R.C. De Coninck
michaeldc@job-base.com
T: +32 2 270.45.74
F: +32 2 270.45.75
C: +32 75 47.62.10
http://www.job-base.com
http://www.c-ware.net
------------------------------
Date: Wed, 22 Sep 1999 17:27:25 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: automatic news poster script
Message-Id: <1k8G3.3489$QJ.198452@typ11.nn.bcandid.com>
In article <37E90A80.F546F696@job-base.com>,
Job-Base <info@job-base.com> wrote:
>Could someone tell me if it is possible to include some part of perl
>code with which it would be able to directly send a message to a usenet
>server. I would like to have the perl script send the data
>automatically without user intervention. But how to do that
Please explain in more detail why you want to do this. I have an
extremely unpleasant suspicion about what you intend to do.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Wed Sep 22 1999
47 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 22 Sep 1999 10:21:30 +0100
From: "Brian" <brian@innovtech.com>
Subject: Re: automatic news poster script
Message-Id: <37e91019$0$225@nntp1.ba.best.com>
Looks like someone is getting ready to spam :-) Hey, the only reason I know
is because I did it myself long ago. Anyway if you have access to a UNIX
box, take a look at the inews utility. It's usually at /usr/local/bin/inews.
Since it's a command line driven tool, you can make calls to it from Perl.
If you had an array of news groups, you just do something like
foreach $newsgroup (@newsgroups){
system(/usr/local/bin/inews <parameters....>)
}
Beware of using this to spam though. You WILL get slapped (I know). In fact
your ISP might just nix your account. It's actually quite interesting all
the algorithms out there that catch spammers. I still get way too much junk
email.
-Brian M.
Job-Base <info@job-base.com> wrote in message
news:37E90A80.F546F696@job-base.com...
> Could someone tell me if it is possible to include some part of perl
> code with which it would be able to directly send a message to a usenet
> server. I would like to have the perl script send the data
> automatically without user intervention. But how to do that
>
> TIA
>
>
> Michael R.C. De Coninck
> michaeldc@job-base.com
> T: +32 2 270.45.74
> F: +32 2 270.45.75
> C: +32 75 47.62.10
> http://www.job-base.com
> http://www.c-ware.net
------------------------------
Date: Wed, 22 Sep 1999 13:22:47 -0400
From: "Robert W. Byrd" <tech@tburg.net>
Subject: Re: batch
Message-Id: <37E91067.68FDB460@tburg.net>
Rasmus Rimestad wrote:
>
> Hi. I've written a perl-script that needs to be executed the first day of
> each month. I've made a function that loops and finds out which date it is,
> but I can't figure out how to start the script.
>
> Any help would be appreciated!
> Rasmus Rimestad, first follower of the blue hen
> | rasmusr@online.no | http://diktringen.cjb.net |
If you are using *nix, cron should fit the bill. If using Win9x, try the
task scheduler.
Hope that helps!
.rob.
--
Robert W. Byrd | Completely Computer Friendly
tech@tburg.net | 67-B Oxford St., Tillsonburg, ON CA N4G 2G3
------------------------------------------------------------
Nothing clever here... >|< ...ereh reverlc gnihtoN
------------------------------
Date: Wed, 22 Sep 1999 11:04:46 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: batch
Message-Id: <37E91A3E.933056A7@mail.cor.epa.gov>
Rasmus Rimestad wrote:
>
> Hi. I've written a perl-script that needs to be executed the first day of
> each month. I've made a function that loops and finds out which date it is,
> but I can't figure out how to start the script.
Others have suggested unix-ish solutions. But you seem to be
submitting your post from a win32 system, so let me point you
toward the Win32 Perl FAQ which comes with installs of ActiveState
Perl. Look for this question in the FAQ:
"How do I schedule jobs on Win32 platforms?"
It has pointers to AT [cron's sickly baby brother], WinAT,
a Perl version of cron, NT Service options, NTcrond, System
Agent, and Task Scheduler.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 22 Sep 1999 15:55:33 GMT
From: c_j_marshall@hotmail.com
Subject: Re: Case insensitive SQL query
Message-Id: <7sau5d$ekl$1@nnrp1.deja.com>
> Instead of flaming the newcomers who demand answers to unPerl
questions,
> why don't we do just like this? I'll answer your MySQL question, but
> only after you answer my macroeconomics question.
>
> *sigh*
>
> Maybe _that_ will help get the point across.
>
>
Perhaps a more challenging method would be to take every inane off-topic
question and drag it kicking and screaming into a perl solution.
I was going to reply to this one by telling him to first pull the entire
table into a hash keyed on the unique field and then loop through using
m/joe/i to select his records.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 22 Sep 1999 11:41:19 -0400
From: "Casey R. Tweten" <crt@kiski.net>
Subject: Re: Checking for space
Message-Id: <Pine.OSF.4.10.9909221136001.17663-100000@home.kiski.net>
On Wed, 22 Sep 1999, kayec wrote:
:I know there are functions for reading directories, coping files... and
:other o/s type functions but what would be the best way to check the
:available drive space??
number_of_platters(PI(r^2))
or, if using tape:
L(W)
--
Casey R. Tweten <joke> This
Web Developer is 100% certified
HighVision Associates virus and bug
crt@highvision.com free code. </joke>
------------------------------
Date: Wed, 22 Sep 1999 10:06:35 +0100
From: "Brian" <brian@innovtech.com>
Subject: Copying directories and subdirectories
Message-Id: <37e90c97$0$216@nntp1.ba.best.com>
First, I am working on Win Nt 4.0 (ugh) and need to copy a directory with
all it's subdirectories and files to another location. I have tried using:
system copy
use File::Find
use File::Copy
readdir()
and combinations of everything I can think of with no luck. Have I just not
had enough coffee? I am hoping I just missed something simple.
Please help if you have a chunk of code lying around that you know works.
Thanks!
-Brian M
------------------------------
Date: Wed, 22 Sep 1999 13:28:52 -0400
From: Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca>
Subject: How to extract data in 'groups'
Message-Id: <37E911D4.836900A0@ccrs.nrcanDOTgc.ca>
Hi,
I'm writing a script to grab values from a text file. My problem is
when I come upon a certain string (eg. TIME), I must extract values from
fields that I've assigned to variables until I reach the TIME string
again. eg.
TIME
W = 2
R = 4
r = 5
TIME
W = 4
R = 8
r = 0
..and so on. I am currently returning how many times the 'TIME' string
is caught, but would like to output a report like:
No of 'TIME' = 2
TIME
W = 2
R = 4
r = 5
TIME
W = 4
R = 8
r = 0
I have tried to do a 'foreach' on all TIME strings found, but can't seem
to get around returning the variables correctly. I've tried assigning
it to an array, but it returns the last INSTANCE of 'TIME' only.
Any ideas would be much appreciated.
Thanks alot
..Tom
-----------------------------------------------------------------------------------------
Tom Kralidis Geo-Spatial Technologist
Canada Centre for Remote Sensing Tel: (613) 947-1828
588 Booth Street , Room 241 Fax: (613) 947-1408
Ottawa , Ontario K1A 0Y7 http://www.ccrs.nrcan.gc.ca
-----------------------------------------------------------------------------------------
------------------------------
Date: Wed, 22 Sep 1999 13:00:42 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: memory use of children
Message-Id: <37E90AAB.56693C89@chaos.wustl.edu>
Bill Moseley wrote:
> Or should I let the system admin worry about such things ;)
/me dons BOFH hat.
. o O ( Hmmm...that jerk programmer has 5 processes soaking up all the
cpu and memory _again_. #ps -fu bill | awk `{print $2}' | grep -V PID |
xargs kill -9; passwd -l bill ...now that's better :)
e.
------------------------------
Date: Wed, 22 Sep 1999 10:42:35 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: memory use of children
Message-Id: <MPG.1252b4e6e752f57098976b@nntp1.ba.best.com>
Elaine -HFB- Ashton (elaine@chaos.wustl.edu) seems to say...
> Bill Moseley wrote:
> > Or should I let the system admin worry about such things ;)
>
> /me dons BOFH hat.
>
> . o O ( Hmmm...that jerk programmer has 5 processes soaking up all the
> cpu and memory _again_. #ps -fu bill | awk `{print $2}' | grep -V PID |
> xargs kill -9; passwd -l bill ...now that's better :)
Oh, but he's forking from a CGI script. What happens when you kill all
the 'nobody' processes. Finally! Some good response time from that
server.
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: Wed, 22 Sep 1999 18:02:27 +0100
From: "sephiroth@id-base.com" <sephiroth@id-base.com>
Subject: Re: mkdir(). What am I doing wrong?
Message-Id: <37E90BA3.20ACD41E@id-base.com>
Kragen Sitaker wrote:
> Standard Linux does not include a Web server. Most Linux
> distributions, however, include Apache,
I admit, I missed that point out.
> which does not behave as you
> describe.
I disagree, it does in my experience.
--
Aaron jp----is----------------------
Dj ShinyBlue--owner--of-------------
http://www.freelocalcalls.com/p3----
http://get.to/blahblur--------------
http://members.dencity.com/blahblur-
------------------------------
Date: Wed, 22 Sep 1999 12:26:42 -0400
From: Juergen Pabel <juergenp@cc.gatech.edu>
Subject: Re: newbie question...well kindof
Message-Id: <37E90342.8EC406E4@cc.gatech.edu>
i know i posted this code
if(not exists $data->{$tmp})
but what i in fact used was
if(not exists $data{$tmp})
the other one was a short guess and didn't work either...sorry for the
confusion
i have seen in the responses that there's no blatant mistake on my part
in the code...(except for copying and pasting the wrong code segment to
this newsgroup :-)
i guess i will have to install a new perl interpreter on my linux box or
find another system with perl so i can see if it's the version that's
buggy...
thanks for all your help!!
jp
------------------------------
Date: Wed, 22 Sep 1999 13:15:18 -0400
From: Juergen Pabel <juergenp@cc.gatech.edu>
Subject: Re: newbie question...well kindof
Message-Id: <37E90EA6.B7BE0FEC@cc.gatech.edu>
hi y'all,
i tested it on a sunOS and it works fine...
jp
------------------------------
Date: Wed, 22 Sep 1999 17:24:50 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: newbie question...well kindof
Message-Id: <Ch8G3.3484$QJ.200562@typ11.nn.bcandid.com>
In article <37E90342.8EC406E4@cc.gatech.edu>,
Juergen Pabel <juergenp@cc.gatech.edu> wrote:
>i know i posted this code
> if(not exists $data->{$tmp})
>but what i in fact used was
> if(not exists $data{$tmp})
>the other one was a short guess and didn't work either...sorry for the
>confusion
>
>i have seen in the responses that there's no blatant mistake on my part
>in the code...(except for copying and pasting the wrong code segment to
>this newsgroup :-)
Since you pasted the wrong code segment, we have no way of knowing
whether there is a blatant mistake in the right code segment or not :)
>i guess i will have to install a new perl interpreter on my linux box or
>find another system with perl so i can see if it's the version that's
>buggy...
I usually find that roughly 95%-99% of cases where an inexperienced
person thinks the compiler or interpreter is broken, it is in fact
their code that is broken.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Wed Sep 22 1999
47 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 22 Sep 1999 12:43:47 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: Newbie question
Message-Id: <37E906B6.9E4F7F4F@chaos.wustl.edu>
Perry King wrote:
> I am completely new to Perl. I am looking for an easy way to connect to a
> web server using an HTTP GET or POST and capture the results coming back for
> subsequent text processing.
Have a look at LWP::Simple
http://search.cpan.org/search?dist=libwww-perl
e.
------------------------------
Date: Wed, 22 Sep 1999 13:23:51 -0400
From: Kevin Genus <genus@ems.att.com>
Subject: PERL GUI Handlers for Winblows 95/98/NT ...
Message-Id: <37E910A7.173D13C5@ems.att.com>
Do any modules exist that would allow perl to do some of the same
functions as Winbatch for automation?
Specifically, things like grabbing a window, issuing key strokes, etc...
Kevin Genus
AT&T
------------------------------
Date: Wed, 22 Sep 1999 12:08:15 -0400
From: HHH <hartleh1@westat.com>
Subject: Re: Perl Module for MS Access?
Message-Id: <37E8FEEF.A06E67D0@westat.com>
One more thing to remember is that MS Access doesn't always use standard
SQL so any SQL statement you send to the Jet engine (using either
DBD-ODBC or Win32::ODBC) may have to be changed if you go to any other
SQL database in the future. Furthermore, not all data types are treated
the same from one SQL database to the next, particularly when one of
them is MS Access.
Henry
jdkronicz@my-deja.com wrote:
> Hi. I am relatively new to Perl and I am looking to use
> it to develope a website with an Access Database. I know
> there are Perl modules for databases like Sybase (Syperl)
> and Oracle (Oraperl) but I can't find one on CPAN for
> Access. Is there one? Should I use one of the more
> generic database modules? How can I get more information
> and / or code examples of how to create an interface to the
> database using Perl?
------------------------------
Date: Wed, 22 Sep 1999 12:16:04 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Problem with method - unblessed
Message-Id: <x3y4sgm7who.fsf@tigre.matrox.com>
"R. Brockway" <rockie@apk.net> writes:
> Hello all,
>
> I am attempting to write a pRPC client/server set of scripts. In my
> Server script I am getting the following error:
>
> Can't call method "Loop" on unblessed reference at ./server1.pl line 43.
You're code is so confusing. Let me point out some mistakes (which
might or might not solve your problem, but will sure help you).
> server1.pl:
>
> #!/usr/bin/perl -wT
> use 5.005;
> #use strict;
uncomment this line :)
> use IO::Socket();
> use RPC::pServer;
>
> my $MY_APPLICATION = "User_Mod";
> my $MY_VERSION = 1.0;
>
> # Function get_user
> sub get_user {
> # take $username and grep from /etc/passwd
> my ($con, $username);
Maybe that is a typo?
my ($con, $username) = @_;
?
> $cmd = ("grep $username /etc/passwd");
$username has not been set to anything. Also, you don't need the
parentheses around the right hand side of the = sign.
> my ($get_user) = "system ($cmd)";
This will not run the system() command. It will set $get_user to the
string 'system (grep /etc/passwd)'. I don't suppose this is what you
want. Also, system() is not the correct function to use if you want to
get the output of your shell commands. Checkout perlfaq8:
Why can't I get the output of a command with system()?
> return (1, $get_user);
> }
>
> # Function quit
> sub quit ($$) {
> my($con, $data) = @_;
> $$data = 0; # tell server's Loop() we are done
> (1, "Bye!");
> }
>
> # Function server
> sub server ($) {
> # process client requests, set up function table
> my ($con) = shift;
Here you set $con to whatever argument was passed to server().
> my ($con, %funcTable);
Here you re-declare $con. This will do two things:
1. It will generate a warning:
"my" variable $con masks earlier declaration in same scope at - line x.
2. It will erase the previous value of $con (which is the argument
passed to the server() function.
This is probably the reason for your error message. Remove $con from
this second declaration.
> my ($running) = 1;
You can lose the parentheses here if you want.
> # Create function table
> %funcTable = (
> 'get_user' => ( 'code' => &get_user ),
This is not the correct way to do what you want to do (which is not
quite clear to me). It looks like you want the value associated with
'get_user' to be a hash reference. Then, you have to use curly braces
{} instead of parentheses ().
> 'quit' => ( 'code' => &quit,
> 'data' => \$running ),
Same thing here.
> );
>
> $con->{'funcTable'} = \%funcTable;
> while ($running) {
> ########### Bad Line Below, shame on you ###############
> if (!$con->Loop()) {
where is Loop() defined? I can't see it. What is $con anyway?
> $con->Log('err', "Exiting\n");
> exit 10;
> }
Maybe you should modify $running here (possibly through an if()
statement) in order to terminate your loop at some point.
> }
> $con->Log('notice', "Client quits.\n");
> exit 0;
> }
>
> # Main
>
> {
> my $sock = IO::Socket::INET->new('Proto' => 'tcp',
> 'Listen' => 3,
> 'LocalPort' => 13000
> );
> while (1) {
> # add configFile to this next line eventually
> my $con = new RPC::pServer('sock' => $sock);
> if (!ref($con)) {
> print STDERR "Cannot Create Server!: $con\n";
> } else {
> if ($con->{'application'} ne $MY_APPLICATION) {
This is BAD BAD BAD practice. Never modify an object's variables
directly. Use methods.
You need to gain a bit more experience with Perl, and all your
problems will be apparent for you.
> thanks to all who can help.
HTH,
--Ala
------------------------------
Date: Wed, 22 Sep 1999 10:59:23 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: REQ: tell-a-friend script
Message-Id: <37E918FB.52627211@mail.cor.epa.gov>
J. Moreno wrote:
[snip]
> Uhm, elsif may be correct perl, but it's still a typo.
A typo of *what* ?
I'm siding with Abigail on this. 'elsif' is a slug of
computer jargon, and is not an English word. It only
needs to remind people of a couple English words. So
it's not strictly a 'typo'. No more than the Unix commands
'mv' and 'cp' are typos because they are not the words
'move' and 'copy'.
Are we far enough off-topic yet?
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 22 Sep 1999 12:26:17 -0400
From: Christopher Woods <ccwoods1@antiquebottlesdot.net>
Subject: Slow runtime - a problem with my server?
Message-Id: <37E90329.3CC7@antiquebottlesdot.net>
Hi
Excuse my ignorance....I am a novice in the perl world.
I have been testing a perl cgi script to send a mailform. It is simple
program that worked great on the website where I downloaded it from.
I have installed it on my web host's server cgi-bin and it works fine,
but it takes 35 to 50 seconds to submit the form!
Is this a problem with my server, did I somehow configure the script
incorrectly, or ?? There is no verification of the email format....this
should be a simple quick task. I have tried a few similar scripts on my
server, and they all take 30 to 60 seconds to submit the form.
THANK YOU.
CC Woods
------------------------------
Date: Wed, 22 Sep 1999 12:51:41 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: Slow runtime - a problem with my server?
Message-Id: <37E9088E.F010FA9E@chaos.wustl.edu>
Christopher Woods wrote:
> I have been testing a perl cgi script to send a mailform. It is simple
> program that worked great on the website where I downloaded it from.
This wouldn't be a Matt Wright script now would it?
> Is this a problem with my server, did I somehow configure the script
> incorrectly, or ?? There is no verification of the email format....this
There is absolutely no way to answer this because a) you didn't show any
of the code in question b) didn't mention what type & version of web
server you are running c) what type of machine and OS it is running on
d) the network connection between client and server e) any type of
performance tuning or lack thereof f) any kind of diagnostic work you
have done.
Web systems performance is a multi-pronged, or horned if you find it
evil, approach to finding a balance between all the processes that need resources.
You should probably take this question to a CGI usegroup where you will
find a bit warmer and possibly more helpful reception.
e.
------------------------------
Date: Wed, 22 Sep 1999 18:25:29 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: sort depth
Message-Id: <37E902F9.35A0633@ife.ee.ethz.ch>
Kragen Sitaker wrote:
>
> In article <7s9ki0$qql$0@216.39.141.21>, Dana Booth <dana@oz.net> wrote:
> >I should have been more specific... This is Perl 5 on an OpenBSD box. I have
> >a textfile containing lines which I would like Perl to sort numerically.
> >Each line is a 23 digit number. And my question would be, to how many digits
> >is the sort function going to work?
>
> If the numbers are right-justified in the column, sorting them as
> strings will sort them correctly. But apparently you tried that and it
> didn't work.
>
> Sorting numerically converts the numbers to integers (if they'll fit)
> or floating-point (otherwise). None of the computers I have around
> here have 23 digits of precision in either integer or floating-point.
>
> So you have to sort by strings.
>
> If the numbers aren't right-justified, you can right-justify them
> before sorting.
or you use Math::BigInt:
my @fields = qw/78432174327843782178432874732897432788974309 6436984321
6748367984326798 74381247032143094320 542095274903271984732743210473
47821470921740937124732784/;
use Math::BigInt;
print "@{[sort {Math::BigInt->new($a)->cmp(Math::BigInt->new($b))}
@fields]}\n";
# or
print "@{[sort {$a->cmp($b)} map {Math::BigInt->new($_)} @fields]}\n";
might not be too fast for large fields :-)
- Alex
------------------------------
Date: Wed, 22 Sep 1999 09:58:35 -0700
From: Harish <hdeshpandeNOvrSPAM@carlson.com>
Subject: System call in windows
Message-Id: <25d0e1ac.1242275f@usw-ex0108-059.remarq.com>
Hi,
The call to 'system('explorer.exe")' returns immediately
eventhough 'explorer' is still running. 'system' I thought
was a blocking call. How can one achieve this.
Thanks in advance and good day.
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Wed, 22 Sep 1999 12:39:16 -0400
From: HHH <hartleh1@westat.com>
Subject: Re: target frame in URL redirection
Message-Id: <37E90634.25E22D94@westat.com>
You are right. Instead of Target= it should have been Window-target:.
When I rattled off this incorrect answer, I was looking at the fact that
the original poster had two "\n"s in the middle of his header which
would cause the second half not to be included in the header.
Next, I should point out that while this may not be part of the HTTP
standard, the original poster did not ask for a complete solution that
will always work and conforms to all appropriate standards. The
question was, "My quess didn't work ... How should I format the line?".
I answered that question. My answer solved the problem for me and it
may have for the original poster. Interestingly, I found the answer in
a FAQ.
HHH
"Alan J. Flavell" wrote:
>
> On Mon, 20 Sep 1999, Kragen Sitaker wrote:
>
> > In article <37E6A12D.135C4BCC@westat.com>, HHH <hartleh1@westat.com> wrote:
>
> > >print "Location: wherever\nTarget=whatever\n\n" ;
> >
> > Target=whatever is not a valid HTTP header line.
>
> The creature has just posted a different answer to the same question, on
> c.i.w.a.cgi, with nary a mention of this thread. Ho hum, another
> candidate for the killfile.
------------------------------
Date: 22 Sep 1999 17:37:14 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Test regex
Message-Id: <eli$9909221246@qz.little-neck.ny.us>
In comp.lang.perl.misc, Samay <samay1NOxoSPAM@hotmail.com> wrote:
> Second takes far less than the first..
> Anyone can find out?
>
> perl -e '"OReilly and The Perl Conference" =~ /i(.+)+i/'
>
> perl -e '"OReilly and The Perl Conference" =~ /i(.+)+e/'
Easy to see why if you enable DEBUGGING in your perl and
add the option '-D520'.
The regex engine can find a match quickly with the second
so it doesn't worry about trying all permutations of ".+"
and "()+" to get a match. Similarly if you try
perl -e '"OReilly and The Perl Conference" =~ /i(.+)+Z/'
The regexp engine can quickly find that there is no match and
give up. (Ilya will probably say that the regexp engine isn't
even invoked and I am being too general.)
The problem arises because the regexp engine is looking for the
exact string 'i', some stuff, and the exact string 'i'. It has
figured out that both of the exact strings exist in the text,
but not that both are in fact the same string and the the RE
will not allow that case to match.
Nested *s and +s are prone to this sort of thing. Adding as
much context as you can helps things out.
Try these two versions of an RE I wrote the other day:
#!/usr/bin/perl
# Add -D520 to above to see trace.
my $HTML = <<'ScriptEnd';
<script><!--
if (a < 10) {
eval(name + ".src = \"" + base + name + ext + "\"");
}
--></script>
ScriptEnd
$| = 1; # Set autoflush
print scalar(localtime) . " -- Begin check1\n";
my $foo = check1($HTML);
print scalar(localtime) . " -- Finished\n\n";
print scalar(localtime) . " -- Begin check2\n";
my $bar = check2($HTML);
print scalar(localtime) . " -- Finished\n\n";
sub check1 ($) {
my $html = shift;
$html =~
s%(< # start tag (open $1)
([^\s>]+) # what this tag is, including /, ($2)
\b # We should have a word boundary here
(?: # non-grabbing parens (A)
[^"'>]+ # simple arguments to the tag
|"[^"]+" # double quoted arguments
|'[^']+' # single quoted arguments
)* # any number of the stuff in (A)
>) # close tag (close $1)
%
&filtertag($2,$1);
%gxe; # g: global, x: extended format, e: eval sub part
return $html;
}
sub check2 ($) {
my $html = shift;
$html =~
s%(< # start tag (open $1)
([^\s>]+) # what this tag is, including /, ($2)
(?: # non-grabbing parens (A)
[^"'>]+ # simple arguments to the tag
|"[^"]+" # double quoted arguments
|'[^']+' # single quoted arguments
)* # any number of the stuff in (A)
>) # close tag (close $1)
%
&filtertag($2,$1);
%gxe; # g: global, x: extended format, e: eval sub part
return $html;
}
sub filtertag ($$) {
my $type = lc(shift);
my $full = shift;
if ($type eq 'a') {
$full =~ s/.*?\b(href=(?:"[^"]+"|'[^']+'|[^>]+)).*/<a $1>/i;
} elsif ($type eq '/a') {
$full = '</a>';
} else {
$full = '';
}
return $full;
}
__END__
Elijah
------
would like you to note that the \b means many comments are left intact
------------------------------
Date: Wed, 22 Sep 1999 13:20:11 +0000
From: Mark Jarvis <mark_jarvis@net.com>
Subject: Using the Expect.pm module w/Perl5.00502
Message-Id: <37E8D78A.6477245D@net.com>
I am now a "rookie veteran". To use the Expect module,
I actually downloaded the new(?) source, recompiled Perl
for Solaris, and installed the IO::Stty, IO::Tty, and Expect
modules. They are at least, available to me now. And I
can write those RegExp things all day long...
The problem I now have is in using the Expect module.
I am migrating something from an Expect (Tcl-based) program
I wrote to the Perl "version" of Expect.
I know how to "expect" something from an object and
look for a pattern, both in Tcl and Perl. But how do I
implement Tcl's "send" function in Perl? Is that one of those
fancy bidirectional pipe things? If so, why am I bothering
with Expect?
In general, what I need to do is this: spawn a process
and send a few things to the process interactively. This
causes the process to generate as much as megabytes of
text, all of which I log and process off-line. I look for a pattern
to indicate that I have all of the text, then nicely close everything
and exit from the spawned process. Done.
Email or posted replies are fine, thanks in advance.
-MJ
-= Will write regular expressions for food. =-
------------------------------
Date: Wed, 22 Sep 1999 17:09:45 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Win32::ODBC.pm hangs CGI.pm under Apache
Message-Id: <t38G3.3449$QJ.198946@typ11.nn.bcandid.com>
In article <7sasth$dja$1@nnrp1.deja.com>, <p.scott@shu.ac.uk> wrote:
>I am using ODBC to hold data which is displayed on a website. I get
>this message with the -w flag:
>
> Use of uninitialized value at C:/Perl/site/lib/Win32/ODBC.pm line 258.
>
>and also for lines 257 and 258.
There's probably a bug in your script where you're passing undefined
values to ODBC. Maybe there's a bug in ODBC.pm.
>If my database has enough rows the
>error messages cause a perl.exe to run forever. Without the -w flag
>everything works.
That's quite astonishing. That should *never* happen. Is it possible
that the -w messages are just making Perl take, say, 100 times as long
as usual?
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Wed Sep 22 1999
47 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 22 Sep 1999 16:45:09 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: You should be admired
Message-Id: <37E905D8.A74C4F18@vpservices.com>
James W Corpening wrote:
>
> Abigail wrote:
>
> > `` I've searched the FAQs, perl.com, and other places, but I haven't found
> > `` a hint as to how to make a hyperlink work as a submit button.
> >
> > What makes you think perl.com would have any information about that?
>
> Ya know, some of you illiterates are real idiots. I write in perl, and I use submit
> buttons in my html portions, as probably many of you do. Consequently, I thought to
> rely on the perl group (the MISC group) to help me.
Ya know, if I had a friend who had two books -- one on Perl and one on
HTML -- and he had a question about submit buttons and hyperlinks and
was looking it up in the Perl book, I would tell him he was looking in
the wrong book. I guess that makes me a real idiot.
--
Jeff
------------------------------
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 877
*************************************