[8523] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2140 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 19 21:08:23 1998

Date: Thu, 19 Mar 98 18:00:32 -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           Thu, 19 Mar 1998     Volume: 8 Number: 2140

Today's topics:
    Re: ? Any Perl scripts already written to print out all <chasecreek.systemhouse@usa.net>
    Re: A matter of timing (Daniel)
    Re: A matter of timing <flavell@mail.cern.ch>
    Re: Appropriate or not ? <chasecreek.systemhouse@usa.net>
    Re: Arrays & hashes <dboorstein@shopcfn.com>
    Re: Bitwise? (Steve George)
    Re: compiling perl <stackhou@execpc.com>
        Cross Platform usage of DBM database <xkaizer@pretzel.com>
        display lines (Chuck Stewart)
    Re: Dynamically checking for existing functions (Andrew M. Langmead)
    Re: Getting another servers environmental variables <chasecreek.systemhouse@usa.net>
    Re: How do you capture command line arguments? (Andrew M. Langmead)
        How to create an environmental variable <dennis.kowalski@daytonoh.ncr.com>
        HTML::Element::extract_links not grabbing frame sources (Brock Sides)
        Irritating procmail business (Ben Evans)
        Kill Signals going to forked System command not Perl sc <siemens@digitalcourier.com>
        Need help with timed execution... jleane@netcom.ca
    Re: Need help with timed execution... <egwong@netcom.com>
        Objects: Effective communication among siblings? <rael@dnai.com>
        Perl Daemons ( Mark Kucera)
        Perl guy/gal needed in San Jose, CA <benjamin@cgusa.com>
    Re: perl script won't work as cgi <brian.charles@orst.edu>
        pRPC troubles <vandevegt@lucent.com>
    Re: Qui sera assez fort pour repondre a ca ?? (Daniel R. Kegel)
        Stinking lousy $*(@#*$@ cmd lin args-HELP <rickryan@mindspring.com>
    Re: Stinking lousy $*(@#*$@ cmd lin args-HELP (Kevin B Cohen)
    Re: Wanted: email address gleaner (John Stanley)
    Re: Way of testing whether a variable is blessed (M.J.T. Guy)
    Re: Way of testing whether a variable is blessed (M.J.T. Guy)
        what is wrong with being a novice ?? <xkn14@dial.pipex.com>
    Re: WinNT + Comm ports + Port Settings (Tye McQueen)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 20 Mar 1998 00:50:51 GMT
From: Sneex <chasecreek.systemhouse@usa.net>
Subject: Re: ? Any Perl scripts already written to print out all of the field names on a form?
Message-Id: <3511BC0F.EC1D143@usa.net>

Run that by me again?!

So, what's your point?  I stated in my private mail to that 'other'
poster the data is in fieldname=pairs anyways - so he would need to
write what amounts to a browser:  'HTML::Parse' or LWP, to see the
fileds, no???

?? Sneex ??

Douglas Clifton wrote:

> Sneex wrote:
> >
> > As I have previous stated via a private mail -
> >
> > It's either CGI.pm or write your own Browser,
> > but hey, why reinvent the wheel :-)
>
> You still don't get it, the original poster
> wanted a script that parses an HTML file,
> *not* and HTML file that calls a CGI to
> determine the names of form input fields.
>
> --
> Douglas Clifton
> Unix/C/Perl/CGI/HTML Programmer
> doug@weboneinc.com





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

Date: Fri, 20 Mar 1998 00:22:38 GMT
From: rkdious@ix.netcom.com (Daniel)
Subject: Re: A matter of timing
Message-Id: <6esckv$eq7@dfw-ixnews3.ix.netcom.com>

>
>> I'm trying to find a way to delay my program for less than a second.
>
>For tchrist's sake, this is a FAQ!  perlfaq8:
>   

I just love how nice and friendly Perl people are in response to a simple 
question.

-Daniel


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

Date: Fri, 20 Mar 1998 02:29:33 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: A matter of timing
Message-Id: <Pine.A41.3.95a.980320022749.40232A-100000@rsplus02.cern.ch>

On Fri, 20 Mar 1998, Daniel wrote:

> >For tchrist's sake, this is a FAQ!  perlfaq8:
> 
> I just love how nice and friendly Perl people are in response to a simple 
> question.

You'd rather drive all the experts away, right, and have a group where
all of us clueless perl newbies are being nice to each other and getting
nowhere? 

-- 

                                  Aggression control?  It's all the rage.




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

Date: Fri, 20 Mar 1998 00:41:04 GMT
From: Sneex <chasecreek.systemhouse@usa.net>
Subject: Re: Appropriate or not ?
Message-Id: <3511B9C4.A24A2409@usa.net>

Birgitt Funk wrote:

> Hi,
>
> Is it appropriate for a beginner who has written his first Perl
> programs, he needs to use for his own business purposes (meaning they
> absolutely
> need to work safely and correctly), to ask experts to test the programs
> and eventually make suggestions how to systematically debug them and
> make them safer ?
>
> <SNIP>
>
> I would appreciate your advice very much.

> Birgitt Funk

  I would say that a code review by your programming peers at work would be
the first step prior to accepting testing.  The hazard level of a program is
related to the task is designed to accomplish, the business risk is related
to 'how many future customers could I lose if this program destroys this
customers files?'

Also, if you do seek out the assistance of a consultant to review/test your
program - make sure they sign a petition not to compete and non-disclosure
agreement.  The reason is that most 'professionals' I know would never
execute 'alpha' code without prior knowledge and they would want to see the
source to make sure there aren't any special precautions that need to be
taken :-)

HTH,
Sneex :-)



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

Date: Thu, 19 Mar 1998 17:10:05 -0500
From: Dan Boorstein <dboorstein@shopcfn.com>
To: Matt Burgoon <infinity@gamersinn.com>
Subject: Re: Arrays & hashes
Message-Id: <351197BD.2417DE80@shopcfn.com>

Matt Burgoon wrote:
> 
> I have an array and hash set up like:
> $accounts[0]{amount}=200;
> $accounts[3]{paid_till}=890338928;
[SNIP]
> $accounts[$_]{thiskey} but I've been trying to set a pointer to that
> particular hash so I don't have to use that entire thing, ex:
> *thishash=\%{ $accounts[$_] };
> So I can simply pull up $thishash{amount} instead of
> $accounts[$_]{amount}.

so here is a sample data structure representing what you have.

@accounts = (
  {
    amount => 200,
    paid_till => 890338928,
  },
);

print $accounts[0]{amount};

# you could just get a reference to the hash at a given index like so,
# and use auto-dereferencing:

$hashRef = $accounts[0];
print $hashRef->{amount};

# or you could copy over the hash by explicity dereferencing at the
# index of interest:

%tinyHash = %{ $accounts[0] };
print $tinyHash{amount};

hope this helps,

-- 
# dan boorstein <dboorstein@shopcfn.com>
seek DATA,0,0;print scalar<DATA>,__END__
Just another Perl hacker,


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

Date: Thu, 19 Mar 1998 16:46:17 -0700
From: stgeorge/$PAMLESS/@amug.org (Steve George)
Subject: Re: Bitwise?
Message-Id: <stgeorge/$PAMLESS/-1903981646180001@d29-ts01.amug.org>

In article <genepoolEq0H4H.I3t@netcom.com>, genepool@netcom.com (Jim
Michael) wrote:


> $A: 1001
> $B: 0011
> 
> $A & $B: 0001
> 
> ~$A: 0110
> ~$B: 1100
> 
> ~$A & ~$B: 0100
> 
> ($A & $B) | (~$A & ~B) = 0001 | 0100 = 0101

Hmm..  Hallo, I'm new to this conf and not sure of exact context, but
isn't that "a bit (!) weighty" if you have exclusive-or (^) availible..?

$A ^ $B:  1010  

This gives "misses," complement for matches. 

Steve G


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

Date: Thu, 19 Mar 1998 18:51:26 -0600
From: Mark Stackhouse <stackhou@execpc.com>
Subject: Re: compiling perl
Message-Id: <6eseqe$h9o@newsops.execpc.com>

Matt,

I think the software you are looking for is called
Perl2Exe.  A trial version can be downloaded from
www.demobuilder.com :-)

--
Mark Stackhouse

***********************************************************************

homepage: http://www.execpc.com/~stackhou

"The best things in life aren't things."
--Art Buchwald

***********************************************************************


Matthew MacGibbon wrote:
> 
> I remember a while back someone had come up with something that allowed
> you to create an executable from a perl script.  Does anyone know
> anything about that?  (or a perl 2 c converter?)


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

Date: Thu, 19 Mar 1998 14:07:01 -0800
From: "Kaizer Sogiawala" <xkaizer@pretzel.com>
Subject: Cross Platform usage of DBM database
Message-Id: <6es55j$da1$1@nntp2.ba.best.com>

I am planning to use DBM database across Unix and Win32 platforms from
within Perl. I am running into a problem where the SDBM database created on
Solaris is not readable from NT (and vice versa). My access to this database
from NT is over the NFS (Hummingbird Maestro NFS client).

After creating the database on Solaris, my attempts to read it from NT
results in garbage getting printed out. To investigate this further, I
created the database on both Solaris and NT. The octal dump of the .pag
files showed that the bytes are swapped. I also attempted to use 'tie' in
the Binary mode. FTPing the .pag files  did not make any difference either.

Looks to me like the network byte order problem. Has anyone come across this
before? I have several other things that come to my mind-

1. Difference in the version of the DBM libraries compiled with perl. Is
there a way to find which version of DBM library is being used?
2. NFS Client not handling the NBO
3. Use Berkley DB. Is it available on Win32 platform?

Thanks in advance.
--
Kaizer Sogiawala
Pretzel Logic Software, Inc.






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

Date: Fri, 20 Mar 1998 00:01:20 GMT
From: cstewart@flash.net (Chuck Stewart)
Subject: display lines
Message-Id: <3511b164.4773204@news.flash.net>

I need to display a delimited file that has 1000 lines at 50 lines at
a time so the html is not so huge.  How can I do this?  Thanks...


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

Date: Thu, 19 Mar 1998 23:38:51 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Dynamically checking for existing functions
Message-Id: <Eq3B0r.Bzx@world.std.com>

bart.mediamind@tornado.be (Bart Lateur) writes:

>	$result = &coder;
>	if (defined $result) { ... }

>This behaves completely differently from

>	if (defined &coder) { ... }


True, but its been that way for quite a long time. 

>"defined \&coder" would have made more sense, I think. But why does

Longer than references have been around.

>	print \&James;

>print something like "CODE(0x153b14)", even though sub James was not
>defined?

Weird. At first I thought it was some sort of autovivication, but it
doesn't exist afterward.

-- 
Andrew Langmead


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

Date: Fri, 20 Mar 1998 00:20:35 GMT
From: Sneex <chasecreek.systemhouse@usa.net>
Subject: Re: Getting another servers environmental variables
Message-Id: <3511B4F6.B5174F85@usa.net>

The CGI.pm module, which is the most likely culprit for the 'server' info display,
does not work like that.  What you are asking for would be like peeking in your
neighbor's windows to see what type of furniture that have.

Sorry,
Sneex :-)


joshmccormack@yahoo.com wrote:

> I've seen the scripts that tell you what the environmental variables are for
> the server you're using (http://www.getscript.com/variable.cgi), but I'd like
> one that could get them for any server. Connected to a form, user puts in name
> (i.e. www.scriptsearch.com) and gets the data. Would I just need to use one of
> the Perl scripts that get your own data and change $ENV to something and make
> an HTML page with a form something like this:
>
> <form action="http://www.getscript.com/variable.cgi" method=GET>
> Enter the name of the site to ask below: (eg. www.phillynews.com)<br>
> <input name=server      value=""        type=text       size=48><br>
> <input name=action      value="Tell me" type=submit>
> </form>
>
> Thanks for the help,
>
> Josh
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/   Now offering spam-free web-based newsreading





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

Date: Thu, 19 Mar 1998 23:53:14 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: How do you capture command line arguments?
Message-Id: <Eq3Bor.L4r@world.std.com>

"rickryan@ Mindspring" <rickryan@mindspring.com> writes:

Subject: Re: How do you capture command line arguments?

Command line arguments are passed in the array @ARGV. Unfortunatly,
web browser and http servers are not child processes of each other, so
that is not they pass information to each other.

>I'm trying to run a perl script directly from the browser's address line as
>follows:

>anyscript.pl?arg1

What you need to do is something like:

use CGI;
my $query = CGI->new();
$value  = $query->param('arg1');

The CGI module is perl module that handles a lot of the low level
details of the CGI protocol. See the CGI man page for more
information.

If you are planning on writing programs that communicate via the CGI
protocol, you might want to take a look at the newsgroup
comp.infosystems.www.authoring.cgi. Thats were all the people doing
CGI stuff hang out.
-- 
Andrew Langmead


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

Date: Thu, 19 Mar 1998 16:29:07 -0500
From: Dennis Kowalski <dennis.kowalski@daytonoh.ncr.com>
Subject: How to create an environmental variable
Message-Id: <35118E23.2C6C@daytonoh.ncr.com>

I am running on a NT 4.0 box.

I need to set up some environmental variables and I want to automate it
with a script.

I have been reading the docs on Win32::Registry.

I think I understand the calls but before I try it and possibley screw
up my registry I would really like to see a small example of some code
that does the following.

  Create a registry entry for a new environmental variable.
  Put a value in the variable

Does anyone have a few lines of code they would share with me ??

Thanks


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

Date: Thu, 19 Mar 1998 18:41:15 -0600
From: opus@magibox.net (Brock Sides)
Subject: HTML::Element::extract_links not grabbing frame sources
Message-Id: <opus-1903981841150001@dave.magibox.net>

I've been writing a web client that uses HTML::Element to pull links out
of pages. Anyway, I'm running into a problem grabbing the sources of
frames. Here's a snippet of code to demonstrate the problem. I'm using
Element.pm v. 1.35.

#!/usr/local/bin/perl

use HTML::Parse;

$html = '<img src="foo.jpg"><frame src="http://www.foo.org" name="foo">';

$parsed_html = HTML::Parse::parse_html($html);

$link_ref = $parsed_html->extract_links();
@link = @$link_ref;

for (@link) {
        print $_->[0], "\n";
}

The output I get is just:

foo.jpg

-- 
Brock Sides opus@magibox.net http://www.magibox.net/~brock/
for(0..4){$humps="."x($_*2+1);$camel.="($humps)"}
"Jtsutona reP reh\nrekcah l"=~/$camel/s;
for(1..5){eval"print scalar reverse \"\$$_\""};


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

Date: 19 Mar 1998 21:26:32 GMT
From: ben@eexpc.eee.nott.ac.uk (Ben Evans)
Subject: Irritating procmail business
Message-Id: <slrn6h33ae.rnd.ben@eexpc.eee.nott.ac.uk>


I have a slight problem with a perl-procmail interaction. I have procmail
calling my perl script:

:0
* ^To.*upload*
{
    :0 c
    uploads
	
    MAILDIR=/secure/s/uploads
    :0
    | upload.pl
}
		    

procmail dumps the mail message fine and starts executing
the script and falls over...

procmail: Executing "upload.pl"
upload.pl: syntax error near unexpected token ;'
upload.pl: upload.pl: line 3: @files = </secure/s/uploads/msg.*>;'

The program's still only being knocked up, I wanted to check it was
switching to the correct directory via the MAILDIR enviroment variable.
Then it started falling over:

#!/usr/bin/perl

@files = </secure/s/uploads/msg.*>;

foreach $file (@files)
{
  open( IN, $file) || die("Can't open $file !!!");
  open( OUT, ">>test.tmp") || die("Can't open test.tmp");
  print OUT "$file\n";
  close( OUT );
  close( IN );
}
	  
and, of course:

gate:/secure/s/uploads$ perl -cw upload.pl
upload.pl syntax OK

Any and all helpful suggestions gratefully received...

Ben
-- 
Ben Evans (Ben.Evans@Swansea.ac.uk) University of Wales, Swansea
"Mathematics students exhibit (in common with their elders) a range of
 behaviour which might cause comment in the outside world" - Korner
 


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

Date: 19 Mar 1998 22:22:30 GMT
From: "Curtis Siemens" <siemens@digitalcourier.com>
Subject: Kill Signals going to forked System command not Perl script
Message-Id: <01bd5386$954e1f50$4331aecc@siemens>

I'm have a problem where kill signals (UNIX, Data General - DG-UX) kill
the forked process from the system command within my perl script,
and therefore don't go to my perl signal handler.  This is causing my
perl script not to clean things up properly.  Example:
-------------------------------------------------------------------
#!/usr/bin/perl
$SIG{'INT'} = 'handler_function';
$SIG{'QUIT'} = 'handler_function';
$SIG{'KILL'} = 'handler_function';
$SIG{'STOP'} = 'handler_function';
$SIG{'ABORT'} = 'handler_function';

$temp_file = "/tmp/temp.file";

system("cat bla bla bla > /tmp/temp.file");

# do stuff

# End of MAIN
exit 0;

sub handler_function
{
  # Remove temporary file(s).
  unlink($temp_file);
}
-------------------------------------------------------------------

In this case if the kill signal (from <Cntrl-C>) comes when
it is performing the "system("cat bla bla bla > /tmp/temp.file");"
it ends up quiting the 'cat', but then the perl script continues.

How can I get it so that kill signals kill the systems commands
and then invoke the perl handler?

Curtis Siemens


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

Date: Thu, 19 Mar 1998 16:42:08 -0600
From: jleane@netcom.ca
Subject: Need help with timed execution...
Message-Id: <6es6sl$ma4$1@nnrp1.dejanews.com>

Hi there, my first post.. scary :)

Anyways... for a daily reminder type thing, I need the script to be executed
at approx. midnight every night on my server.  I have the rest of the code
worked out, but I'm pretty puzzled in this regard... and I'm sure my sysadmin
would gank me for just starting the script at midnight and using
"sleep(bignum);" to wait 24 hours :)

TIA,
jason

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Thu, 19 Mar 1998 23:28:12 GMT
From: Eric Wong <egwong@netcom.com>
Subject: Re: Need help with timed execution...
Message-Id: <egwongEq3AJ0.9Ex@netcom.com>

jleane@netcom.ca wrote:
: Hi there, my first post.. scary :)

: Anyways... for a daily reminder type thing, I need the script to be executed
: at approx. midnight every night on my server.  I have the rest of the code
: worked out, but I'm pretty puzzled in this regard... and I'm sure my sysadmin
: would gank me for just starting the script at midnight and using
: "sleep(bignum);" to wait 24 hours :)

Well, if you're on a unix-y system, check out cron(8) and crontab(1).
Chances are you'll need your system administrator's help to get into 
the /etc/at.allow or whatever.  Alternatively, if you're the type to
leave your computer on all of the time, you can have your home computer
call up at midnight to execute the script.   Or if you can insert a cron
job on another computer, you can have that computer send out an e-mail
around midnight to your server and use procmail or something to execute
the script.

Anyhow, if it's a "daily reminder thing", why not just have the script 
run when you log in?  After all, I presume you're not going to be 
accessing the data without being logged on, right?  Or, perhaps, you
have some kind of human-computer ESP :)



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

Date: Thu, 19 Mar 1998 16:13:20 -0800
From: "Rael Dornfest" <rael@dnai.com>
Subject: Objects: Effective communication among siblings?
Message-Id: <6esc7r$i14$1@castor.dnai.com>

Hi Folks,

I've performed a fairly comprehensive scan of the Perl books, FAQs, MAN
Pages, and newsgroups but can't seem to find much on the topic of an
object referencing its siblings.  What I mean is...

I have an array of objects -- let's call it @array_of_objects.
I want each object to be able to communicate with its siblings -- in
other words, I want $array_of_objects[0] to be able to talk to a method
lookup() in $array_of_objects[1] and vice-versa.

Is there a snazzier method than passing in a reference to the
array @array_of_objects?

Any help would be greatly appreciated.

Rael




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

Date: Fri, 20 Mar 1998 09:37:41 GMT
From: kucera@mindsrping.com ( Mark Kucera)
Subject: Perl Daemons
Message-Id: <3512389d.8190327@news.mindspring.com>

hi, i have a perl script that i want to make into a daemon.  how would
i go about doing it?  

i have seen some programs for win32 that change perl scripts to exe
files? is there a similar program for unix?

thanks for your help..

mark kucera
kucera@mindspring.com


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

Date: Thu, 19 Mar 1998 16:30:58 -0800
From: "Benjamin Rosenthal" <benjamin@cgusa.com>
Subject: Perl guy/gal needed in San Jose, CA
Message-Id: <6esdem$jl0$1@toro.bais.com>

I have a contract and/or full-time position available in San Jose, CA.  Send
resumes to benjamin@cgusa.com ASAP.

REQUIRED SKILLS:
*       Mid-level Perl Programming experience (1-3 years); experience should
be mostly with Perl 5.x
*       Understanding of how to build Perl interfaces to databases and work
with most popular databases
*       Familiarity with HTML
*       Experience in working in a team environment
*       Understanding of corporate culture in a start-up business
*       Responsible, highly motivated individual

PROJECT DATA:
*       Development of Perl applications for the Web environment
*       UNIX operating system/understanding of NT a plus
*       Database normalization and basic schema development
*       Complex CGI script development

DAY TO DAY DUTIES:
*       Mostly programming and product development
*       Weekly client contact
*       Some product implementation
*       Some training

WORKING ENVIRONMENT:
*       On-site in downtown San Jose (near light-rail in the Software
Business Cluster)
*       Great entrepreneurial exposure (fast-growing, start-up)




****************************************************************************
***********
Benjamin Rosenthal   email:  benjamin@cgusa.com
Carnaghe and Gibbs   voice:  (415) 956-6400 x20
Business Solutions, Inc   fax:     (415) 956-6450






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

Date: Thu, 19 Mar 1998 15:39:01 -0800
From: Brian Charles <brian.charles@orst.edu>
Subject: Re: perl script won't work as cgi
Message-Id: <3511AC95.4DA75B49@orst.edu>

Thanks for the help. It works fine now.

Doran L. Barton wrote:

> I don't see the required MIME headers anywhere in your code. Add this at the
> top of your script:
>
> print "Content-type: text/html\n\n";
>





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

Date: Thu, 19 Mar 1998 17:23:26 -0600
From: Jim VandeVegt <vandevegt@lucent.com>
To: wiedmann@neckar-alb.de
Subject: pRPC troubles
Message-Id: <3511A8EE.927F9ED5@lucent.com>

I am trying to get started with the pRPC package.  I have read the
documentation and have used a subset of the example given to attempt a
test.  I have also looked over the code for pNETagent, which is working
great for my remote Informix connections.  I seem to have everything
included, but I receive the following error on the server right after
the client connects.  I dug into the modules and added some debugging
statements.  The code is looking at a 60 byte message when the error
occurs.  I looked at the packet with snoop, and it looks like everything
is there.  I'm using the latest versions of perl, Storable, IO, and
pRPC.

(All debugging output included for verbosity)
server: Execution starting.
server: funcTable set up.
Socket created
Accepting connect from 135.159.1.3, port 9052
RPC::pServer: Waiting for client to log in.
Not a scalar string at
/home1/ohdvlp/perl5.00404/lib/site_perl/auto/Storable/thaw.al line 13,
at /home1/ohdvlp/perl5.00404/lib/site_perl/RPC/pClient.pm line 307

My code and server configuration file is attached.

pServer.cf:
accept .*
    user jmv

===========================================
server:
#!/home1/ohdvlp/perl5.00404/bin/perl -wT

use 5.004;
use IO::Socket;
use RPC::pServer;
use strict;

sub sum ($$$$) {
 my ($con,$data,$one,$two)= @_;
 # Example: add $one and $two
 warn "server: executing sum\n";
 return (1,$one + $two);
} # sum

sub main {
 my (%funcTable,$connection,$sock,$running);

 my $myapp= "RPC Test";
 my $myversion= "1.0";
 my $port= 9052;

 warn "server: Execution starting.\n";
 %funcTable= (
  'sum' => {'code' => \&sum}
  );
 warn "server: funcTable set up.\n";

 $sock= new IO::Socket::INET
  ('LocalPort'=>$port,
  'Proto'=>'tcp',
  'Listen'=>5,
  'Reuse'=>1) || die "Couldn't create socket $!\n";

 warn "Socket created\n";
 $connection= new RPC::pServer (
  'sock'=>$sock,
  #'cipher' => undef,
  'stderr' => 'TRUE',
  'debug' => 10,
  'configFile' => "pServer.cf");

 warn "RPC::pServer returned\n";

 die "server: Cannot create server: $connection\n"
  if !ref($connection);

 warn "server: Connection made\n";

 if ($connection->{'application'} ne $myapp) {
  $connection->Deny("This is a $myapp server, Bye");
 } elsif ($connection->{'version'} != $myversion) {
  $connection->Deny("Sorry, I talk protocol version $myversion");
 } else {
  $connection->Accept("Welcome");
  warn "server: Accept\n";
  $connection->{'funcTable'}= \%funcTable;
  warn "server: function table reference set\n";
  while ($running) {
   warn "server: connection loop\n";
   if (!$connection->Loop()) {
    $connection->Log('err',"Exiting.\n");
   }
  }
  warn "server: out of main loop\n";
  $connection->Log('notice',"Client quits.\n");
 }
} # main

&main;

=====================================
client:
#!/home1/ohdvlp/perl5.00404/bin/perl -wT

use 5.004;
use IO::Socket;
use RPC::pClient;
use strict;

sub main {
 my $myapp= "RPC Test";
 my $myversion= 1.0;
 my $port= 9052;

 my $sock= new IO::Socket::INET (
  'PeerAddr' => 'oheis.oh.lucent.com',
  'PeerPort' => $port,
  'Proto' => 'tcp') ||
   die "Couldn't create socket $!\n";

 warn "Socket created\n";
 my $conn= new RPC::pClient(
  'sock' => $sock,
  'application' => $myapp,
  'version' => $myversion,
  'user' => "jmv",
  'password' => "whoppy");

 if (!ref($conn)) {
  die "Cannot create client: $conn\n";
 }

 warn "RPC connection made\n";
 my $a= $conn->Call('sum', 3, 4);
 if ($conn->error) {
  die "Error calling sum: $a\n";
 }

 print "I got answer $a\n";
 exit 0;
} # main

&main;

=================================
The client output is simply "socket created" and it hangs.  The server
process exits with the above error.

Thanks for any help.
----
Jim VandeVegt
vandevegt@lucent.com



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

Date: 19 Mar 1998 22:50:06 GMT
From: dank@alumnae.caltech.edu (Daniel R. Kegel)
Subject: Re: Qui sera assez fort pour repondre a ca ??
Message-Id: <6es7eu$kfo@gap.cco.caltech.edu>

"Eric D. Friedman" <friedman@uci.edu> writes:
>... However (and I don't say that Tom implied
>anything to the contrary), native English speakers would still do well
>to pick up another language.  I participate in french-language
>listservs on technical topics (not Perl, alas), and have often found
>useful information there.  Recently, I was able to resolve a rather
>nasty linux-alpha problem by following the advice I found in a
>german-language group archived at Dejanews.
>
>There's lots of talent out there, and I consider myself fortunate to
>be able to draw on it.

I agree.  The days of English-only Internet are drawing to a close.
I see more and more other languages popping up in the newsgroups I read.
My German and French skills are getting a much better workout these days!

One thing stopping a lot of US kids from learning a foreign language
is - you never hear or see any foreign languages!  The Internet has 
already started changing this.  Now if only there were good internet
radio in French and German... 
- Dan


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

Date: Thu, 19 Mar 1998 16:20:18 -0600
From: "rickryan@ Mindspring" <rickryan@mindspring.com>
Subject: Stinking lousy $*(@#*$@ cmd lin args-HELP
Message-Id: <6es594$fqs@camel20.mindspring.com>

I'm trying to capture a command line argument from within a perl script. I
realize it's not rocket science and I've spent the whole day searching for
the answer. Here's what I'm doing: (on yea, it's running on an NT server)

(this is typed in from the browser's address prompt)

script.pl?arg1

I've tried every method I can think of; stdin, Getopt, ARGV, $_[0], nothing
works.

HElp!?






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

Date: 19 Mar 1998 17:50:55 -0500
From: kcohen@julius.ling.ohio-state.edu (Kevin B Cohen)
Subject: Re: Stinking lousy $*(@#*$@ cmd lin args-HELP
Message-Id: <6es7gf$27b@julius.ling.ohio-state.edu>

In article <6es594$fqs@camel20.mindspring.com>,
rickryan@ Mindspring <rickryan@mindspring.com> wrote:
>I'm trying to capture a command line argument from within a perl script. I
>realize it's not rocket science and I've spent the whole day searching for
>the answer. Here's what I'm doing: (on yea, it's running on an NT server)

i'm not sure how you're passing in the command line, but the general
deal is:

1) argv exists, but it's called @ARGV.  the first thing after the name
of the script is $ARGV[0].

2) so, here's a command line a la my NT system:

perl kevins_script.pl latvian lithuanian estonian finnish

3) and here's a snippet of kevins_script.pl:

$baltic_country1 = shift(@ARGV); # baltic_country1 is latvian
$baltic_country2 = shift(@ARGV); # baltic_country2 is lithuanian
$baltic_country3 = shift(@ARGV); # baltic_country3 is estonian

OR

$baltic_country1 = $ARGV[0]; # see above comments
$baltic_country2 = $ARGV[1];
etc.

s/country/language/, and it's true, as well as perl.

kevin



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

Date: 20 Mar 1998 01:17:12 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Wanted: email address gleaner
Message-Id: <6esg2o$4ut$1@news.orst.edu>

In article <350FEE89.5AB9@glpbooks.BADMAIL.com>,
Jeff Potter  <jp@glpbooks.BADMAIL.com> wrote:
>Do you call posts from your mom spam, too? 

If my Mom were to grep a newsgroup for addresses to send email to, and
sent the same email to each person, yes, damn right, that email would be
spam. My mother, however, is not that stupid, nor is she that rude. And
I resent you comparing yourself to my mother.

>Please, give a reason as to why the above might be spam. 

Unsolicited commercial garbage sent to many people. Bingo.

>---It's a specific response to a specific post. 

Baloney. You are going to ask the same thing in each of the messages.
"Can I steal your work to make money for myself by publishing it in a
book?" It doesn't matter if you cut and paste text from different
articles, the question is the same, and it was spam when it was done by
a book publisher who posted the requests to USENET, too, even though he
included a section of the group charter to make them look different.

>It's *ontopic* to both the newsgroup and the specific posts involved.

Baloney. Asking someone if you can steal their work to make money for
yourself is not on topic in any newsgroup I know of, unless there is an
alt.can.I.steal.your.work newsgroup somewhere.

>Unless you're against books being created from NG archives, there's nothing
>'spamlike' about my quest. 

There is everything spamlike about your quest, whether or not I am
against you publishing a book of other people's articles. You have a
strange idea of what a newsgroup archive is supposed to be for. It isn't
supposed to be for you to make money off of.

>If you're against such activity, that's one thing.

And what "one thing" would that be? 

>But posts about the subject are absolutely not spam. 

They are not "posts" about the subject, they are email, and they are not
about any subject other than how you can make money using other people's
work.

You picked the wrong group to ask how to spam. You picked the wrong
group to ignore advice from that what you want to do is spamming.



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

Date: 20 Mar 1998 00:26:49 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Way of testing whether a variable is blessed
Message-Id: <6esd49$77l$1@lyra.csx.cam.ac.uk>

Ronald J Kimball  <rjk@coos.dartmouth.edu> wrote:
>Martin Vorlaender wrote:
>> 
>> Allen Choy (achoy@us.oracle.com) wrote:
>> : Is there a standard way of testing whether a variable is blessed or not?
>> 
>> ref($var) !~ /^(?:REF|SCALAR|ARRAY|HASH|CODE|GLOB)$/;
>> 
>> Or is there anything else ref() could return if $var isn't blessed
>> into a package?
>
>Whether or not there is now, there could conceivably be new built-in types
>added in the future, in which case that code would no longer work.

There already are (or soon will be)  LVALUE, IO and FORMAT, and I've
probably forgotten some other case.

>print "Blessed.\n" if $var =~ /=/;

Diddling with the syntax of ref() is almost as disreputable as the above
suggestion.    The right way is

  print "Blessed.\n" if $var && UNIVERSAL::can($var, 'can');

( Note:  -w clean unlike some other postings.)


Mike Guy


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

Date: 20 Mar 1998 00:29:33 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Way of testing whether a variable is blessed
Message-Id: <6esd9d$77v$1@lyra.csx.cam.ac.uk>

In article <35095F5D.7765@min.net>, John Porter  <jdporter@min.net> wrote:
>Allen Choy wrote:
>> 
>> Is there a standard way of testing whether a variable is blessed or not?
>> 
>> The only way I can think of is testing whether a reference has an '='
>> sign.
>
>Kludgy: the stringized form of a ref is not guaranteed to always look
>as it does now.
>
>A semi-canonical way is to test for the ability to call the 'can'
>method.  Since (currently) all blessed things have UNIVERSAL in
>their superclass tree implicitly (not in any ISA list).
>
>sub is_blessed {
>  eval { $_[0]->can('can') };
>  ! length($@);
>}

Nice try, but it's a bit silly to apply a method to something which may
not be an object.    Instead do

    $x && UNIVERSAL::can($x, 'can')


Mike Guy


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

Date: 19 Mar 1998 22:00:02 GMT
From: "Jon Marshall" <xkn14@dial.pipex.com>
Subject: what is wrong with being a novice ??
Message-Id: <01bd5381$62758f00$474295c1@default>

Dear all

i have just read yet another question from a newbie/novice who fully
expects to get flamed for simply asking about something he doesn't
understand. this doesn't seem a very healthy attitude to engender in people
especially considering the popularity of perl. i am not trying to lecture
anybody as to what they should or should not do and i am by NO means an
expert in perl - there are a lot of things i still don't get - so you could
just tell me where to get off, but i thought newsgroups were there, among
other things to help people with a common interest, not to scare them off.
I do agree with a certain amount of the criticism levelled at some of the
questioners - this is not a CGI newsgroup ( my main gripe - perl can be
used for other things ! ) and some people just can't seem to get that, nor
should this be a newsgroup for people who really can't be bothered to even
try and find the answer to their problem, either by looking it up or just
plain perseverance with their script. 
That said if someone really has made an effort and they simply don't get it
surely this should be one of the main places to go for an
explanation/answer - sure some of the questions will be basic and the
answer might be found in the FAQ or more likely the Camel book ,but if perl
is your first language, or your only exposure prior to this was something
like shell scripting then the Camel book can be difficult to downright
unintelligible, we are not all C programmers, and there is a huge leap
between Learning Perl and Programming in Perl. 
I can understand and appreciate why some people get very frustrated,
especially the more experienced people  and perhaps there is a good
argument for a separate group for the less knowledgeable programmers, but
then would  the people who could actually answer the questions ever read it
!. I'm not saying i know the solution but i feel strongly that people who
are making an effort to learn perl should not be scared off simply because
of their inability to grasp something which might, to a far more
experienced person be blindingly obvious. 
 
Jon Marshall


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

Date: 19 Mar 1998 16:50:21 -0600
From: tyde@medtrodnet.cdom (Tye McQueen)
Subject: Re: WinNT + Comm ports + Port Settings
Message-Id: <6es7fd$stt@fohnix.metronet.com>

James Bateman <james.bateman@mail.com> writes:
) I would like to send out a simple sequence of characters to a comms
) port, but first I would like to set it to a particular settings (baud
) rate etc).
) 
) While I can do this by first calling the 'mode.com' command via the
) system function, this isn't very neat. Is it possible to change the port
) settings via the register, ie modifying
) HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports,
) if so how).

You might be able to change the port speed by modifying the
Registry _and then rebooting_.  So I think "mode.com" is a
better alternative.

Work on a Win32 Serial Port module has started (I'd point you to
the author but I'm not sure which of his e-mail addresses to use
and I think the announcements aren't as public as c.l.p.m yet)
but "mode.com" is a perfectly reasonable solution in the mean time.
If, however, you want to specify a timeout while reading or not
wait for newlines, then a good solution probably isn't available
yet.

You really should search at www.dejanews.com before posting so
you don't go asking the same question that fifty other people
already asked this week.  Also, if you can find one that works,
search an archive of the Perl-Win32-* e-mail lists and you'll
probably find more info.

Good luck,
--
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
       Remove d's from address to reply (sorry for the inconvenience).


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

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

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