[14046] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1456 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 22 12:06:00 1999

Date: Mon, 22 Nov 1999 09:05:19 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <943290318-v9-i1456@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 22 Nov 1999     Volume: 9 Number: 1456

Today's topics:
    Re: "The Art of Perl" (was Re: Perl programming sytle) <j.mohr@gisma.de>
    Re: "The Art of Perl" (was Re: Perl programming sytle) <slanning@bu.edu>
        [Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
        Binary scanning. <epovazan@bc.sympatico.ca>
    Re: Binary scanning. <lr@hpl.hp.com>
        can i view the perl program <praburam@sprint.ca>
    Re: can i view the perl program <rhomberg@ife.ee.ethz.ch>
    Re: Can Perl Answer Prompts (Bart Lateur)
    Re: can't find db.h lib.db (2nd post) (Anno Siegel)
        Charts  mirak63@yahoo.com
    Re: Charts <tony_curtis32@yahoo.com>
    Re: Encryption Algorithm for Perl Source Code?? - activ (Tad McClellan)
    Re: environment vars <cpcollin@wam.umd.edu>
    Re: environment vars <uri@sysarch.com>
    Re: Error Using Access db Created in a Workgroup <carrie.sullivanNOcaSPAM@colorspan.com.invalid>
    Re: exists causes internal server errors!! <moseley@best.com>
    Re: file descriptors already used when perl starts g0177325@my-deja.com
        FIXED:Re: Simple s#this string#that string# doesn't wor <rjsmith@uk.oracle.com>
    Re: Fork Children w/ Expect <jim.mosier@usa.net>
        FTP in PERL, cmd line args etc. (Linda Minnich)
    Re: Help w/ DBI (Adam Levenstein)
    Re: Help w/ DBI <gellyfish@gellyfish.com>
        Help with TCP sockets please marius_13@my-deja.com
    Re: How to create file in other directory ? (Matthew Bafford)
    Re: How write records to ASCII file (Brett W. McCoy)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 22 Nov 1999 15:44:22 +0100
From: James Mohr <j.mohr@gisma.de>
Subject: Re: "The Art of Perl" (was Re: Perl programming sytle)
Message-Id: <383956C6.444657DA@gisma.de>

Josh Geller schrieb:

> In article <Y7gZ3.277$AQ2.22013@newshog.newsread.com>,
> Scott McMahan <scott@aravis.softbase.com> wrote:
>
> >> I was recently "chastised" by someone for programming perl on  WinNT
> >> like I program C on UNIX. He insisted that I should programm more
> >> "perl-like" and many of the constructs he suggested as changes were
> >> definately not C-like, and were definately harder to read. (IMO)
>
> Sounds like an asshole.

I wasn't going to use that exact expression, but that is my impression, as
well. There
were also many place where I was "wrong" for not using the exact syntax he
would
have.


> > My opinion is that he needs something better to worry about.
>
> Or a good smack upside the head, one.

--
Regards,

jimmo
---------------------------------------
"Science has promised man power...But, as so often happens when
people are seduced by promises of power, the price is servitude
and impotence.  Power is nothing if it is not the power to choose."
Joseph Weizenbaum of MIT said in reference to Computers.
---------------------------------------
The Great Linux-NT Debate: <http://www.jimmo.com/Debate/intro.html>




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

Date: 22 Nov 1999 11:41:14 -0500
From: Scott Lanning <slanning@bu.edu>
Subject: Re: "The Art of Perl" (was Re: Perl programming sytle)
Message-Id: <kusn1s6pjh1.fsf@buphy.bu.edu>

James Mohr <j.mohr@gisma.de> writes:
>There were also many place where I was "wrong" for not using the exact
>syntax he would have.

Steeeempy, you eee-diot!


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

Date: Mon, 22 Nov 1999 11:24:01 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage943269841.26699@news.teleport.com>

Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 18 Aug 1999

[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last major update of the Perl FAQ was in Summer of
1998; of course, ongoing updates are made as needed. ]

For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).

    http://www.cpan.org/doc/FAQs/

Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.

    perldoc perlfaq
    man perlfaq

If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.

If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.

    http://www.cpan.org/
    http://www.perl.com/CPAN/
    http://www.cpan.org/doc/FAQs/FAQ/html/
    http://www.perl.com/CPAN/doc/FAQs/FAQ/html/

You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)

    California     ftp://ftp.cdrom.com/pub/perl/CPAN/
    Texas          ftp://ftp.metronet.com/pub/perl/
    South Africa   ftp://ftp.is.co.za/programming/perl/CPAN/
    Japan          ftp://ftp.dti.ad.jp/pub/lang/CPAN/
    Australia      ftp://cpan.topend.com.au/pub/CPAN/
    Netherlands    ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
    Switzerland    ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
    Chile          ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/

If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
Another possibility is to use one of the FTP-via-email services; for
more information on doing that, send mail to <mail-server@rtfm.mit.edu>
(not to me!) with these lines in the body of the message, flush left:

    setdir usenet-by-group/news.announce.newusers
    send Anonymous_FTP:_Frequently_Asked_Questions_(FAQ)_List

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.

Have fun with Perl!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/


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

Date: Mon, 22 Nov 1999 05:30:12 -0800
From: "X" <epovazan@bc.sympatico.ca>
Subject: Binary scanning.
Message-Id: <avb_3.5$jf7.82333@news.bctel.net>

Hello All,

I am very new to Perl, and finally have a handle on regex stuff. What
pleasure.
I need to import a lot of binary data (specifically parse 3d file formats to
my own format) and I was wondering if Perl can apply regex to binary data? I
don't see why it shouldn't since many of the formats have "magic numbers"
associated with chunks of coordinates etc.
So I would need to make Perl ignore whitespace and newlines, and then scan
as normal ?? Does perl do any magic internally that would give me surprises,
e.g. PCs newline is different to unix (13 10 as opposed to 10 I think ...
can't remember but newline and linefeed).

I've been doing this stuff in C++ and though it might be efficient in terms
of speed, it is a major PITA in all other ways. And importing is done once
only.

Thanks
-Ed





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

Date: Mon, 22 Nov 1999 08:10:54 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Binary scanning.
Message-Id: <MPG.12a30aeb7176035a98a24f@nntp.hpl.hp.com>

In article <avb_3.5$jf7.82333@news.bctel.net> on Mon, 22 Nov 1999 
05:30:12 -0800, X <epovazan@bc.sympatico.ca> says...
> I am very new to Perl, and finally have a handle on regex stuff. What
> pleasure.

How true!

> I need to import a lot of binary data (specifically parse 3d file formats to
> my own format) and I was wondering if Perl can apply regex to binary data? I
> don't see why it shouldn't since many of the formats have "magic numbers"
> associated with chunks of coordinates etc.
> So I would need to make Perl ignore whitespace and newlines, and then scan
> as normal ?? Does perl do any magic internally that would give me surprises,
> e.g. PCs newline is different to unix (13 10 as opposed to 10 I think ...
> can't remember but newline and linefeed).

That's 'return' and 'linefeed'.

Instead of 'ignore whitespace and newlines', I presume you mean to treat 
them literally and not interpret them.  Use the binmode() function on 
any stream that deals with binary data, before doing any operation using 
that stream.  Do this no matter what OS the program is running under!

For a bit more discussion,

perldoc -f binmode

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 22 Nov 1999 10:08:26 -0400
From: "Praburam Conjeevaram" <praburam@sprint.ca>
Subject: can i view the perl program
Message-Id: <IYb_3.7527$MM.262238@newscontent-01.sprint.ca>

HI
Do i need a CGI_BIN to view my perl program.
CAn i upload the perl program and view on the IE
if so how to do it.

--
-Prabu








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

Date: Mon, 22 Nov 1999 15:17:08 +0100
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: can i view the perl program
Message-Id: <38395064.428EDC88@ife.ee.ethz.ch>

> Do i need a CGI_BIN to view my perl program.
No
> CAn i upload the perl program and view on the IE
> if so how to do it.

I am sure you can upload the program and configure the server so
it shows it on request.
AFAIK you can look at it locally, with "load file" if IE recognizes the
extension.

Your questions neither belong in this newsgroup nor do they make much
sense. I'd rather use a text editor to look at a program than IE.

- Alex


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

Date: Mon, 22 Nov 1999 14:46:43 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Can Perl Answer Prompts
Message-Id: <383f43e4.5033711@news.skynet.be>

Nico Zigouras wrote:

>There is a Perl module called Expect like
>use Expect;
>that can do all of the expect stuff.

 ... just like you would expect. Sorry, I couldn't help it. :-)

-- 
	Bart.


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

Date: 22 Nov 1999 15:21:04 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: can't find db.h lib.db (2nd post)
Message-Id: <81bn10$ao8$1@lublin.zrz.tu-berlin.de>

Waranun Bunjongsat  <bunjonwa@trek.CS.ORST.EDU> wrote in comp.lang.perl.misc:
>Hi,
>
>	Sorry about disturbing you guys again .....
>	I have a question that I tried to build DB_File, but I can't find
>db.h and lib.db. Are they supposed to come with Perl5 ?

They don't.  You can get them from sleepycat.com.

Anno


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

Date: Mon, 22 Nov 1999 18:05:55 GMT
From: mirak63@yahoo.com
Subject: Charts 
Message-Id: <38398597.513034515@news.vnet.net>

Hello, 

Are there any PERL modules that provide for the development of Charts
or Graphs?

I've been looking all over and can't find anything.

Thanks,
Karim Wall
mirak63@yahoo.com


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

Date: 22 Nov 1999 15:08:41 +0000
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Charts
Message-Id: <wk903q1s3p.fsf@yahoo.com>

mirak63@yahoo.com writes:

> Hello, 
> 
> Are there any PERL modules that provide for the development of Charts
> or Graphs?
> 
> I've been looking all over and can't find anything.

http://www.cpan.org/

  ->

  http://www.cpan.org/modules/index.html

    -> "by category"

      http://www.cpan.org/modules/00modlist.long.html#18)Images,Pixma

hth
tony


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

Date: Mon, 22 Nov 1999 04:41:56 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Encryption Algorithm for Perl Source Code?? - activator.cgi (0/1)
Message-Id: <slrn83i3v4.7hv.tadmc@magna.metronet.com>

On Mon, 22 Nov 1999 02:03:03 GMT, jut@letterbox.com <jut@letterbox.com> wrote:

>On Sun, 21 Nov 1999 20:00:03 GMT, *@dragons.duesouth.net (Matthew
>Bafford) wrote:
>
>>[Please place your replies below the message you are replying to.  This
>> lets people quickly glance over the previous message and freshen up on
>> what's going on.]
>>
>
>Sorry, I'm kinda new to this.


   But he just asked you to put your reply following the piece of
   text that your reply applies to.

   So how come you aren't doing that, now that you know it is expected
   of you?



      news.announce.newusers

   is a newsgroup that describes how to use Usenet without
   pissing people off.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 22 Nov 1999 09:15:12 -0500
From: "Chris Collins" <cpcollin@wam.umd.edu>
Subject: Re: environment vars
Message-Id: <81bj6t$f3g$1@hecate.umd.edu>

You solved my problem, I just had to include the previous path in my
LD_LIBRARY_PATH,
now I'm set.  Thanks.

Chris

Uri Guttman <uri@sysarch.com> wrote in message
news:x7zow8o5a0.fsf@home.sysarch.com...
> >>>>> "JS" == Jonathan Stowe <gellyfish@gellyfish.com> writes:
>
>   JS> On Sat, 20 Nov 1999 18:48:05 -0500 Chris Collins wrote:
>
>   >> I think that is on the right track (the LD_LIBRARY_PATH thing) I
>   >> don't think I know exactly what to put in that path.  I put the
>   >> paths of the two files mentioned in the web server's error_log that
>   >> it wasn't able to open, but all that did was cause my working
>   >> script (from the command prompt) to give the same error I had been
>   >> receiving in the webserver logs.
>
>   JS> You will probably need to ask in an oracle group to get the right
>   JS> answer but basically you need to have LD_LIBRARY_PATH point to the
>   JS> places where your oracle libraries reside - as an example I have
>   JS> Informix installed on this machine and I would add the following to
>   JS> the LD_LIBRARY_PATH :
>
>   JS>      /usr/informix/lib:/usr/informix/lib/esql
>
> i think use PSI::ESP may come to the rescue. when he changed
> LD_LIBRARY_PATH for the shell it failed the same way. i am now divining
> that he forgot (or was never told) to put the standard lib paths in that
> var too! by default, libraries are searched for in usually just
> /usr/lib. if LD_LIBRARY_PATH is set, that is the list of dirs to search
> and the default is not searched. so set it to:
>
> /usr/lib:/usr/informix/lib:/usr/informix/lib/esql
>
> so that will find all the standard and informix libraries. if perl is
> installed in /usr/local, add /usr/local/lib to that. and make sure the
> informix paths are correct.
>
> uri
>
> --
> Uri Guttman  ---------  uri@sysarch.com  ----------
http://www.sysarch.com
> SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX
Consulting
> The Perl Books Page  -----------
http://www.sysarch.com/cgi-bin/perl_books
> The Best Search Engine on the Net  ----------
http://www.northernlight.com




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

Date: 22 Nov 1999 10:39:05 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: environment vars
Message-Id: <x7so1yo7s6.fsf@home.sysarch.com>

>>>>> "CC" == Chris Collins <cpcollin@wam.umd.edu> writes:

  CC> You solved my problem, I just had to include the previous path in my
  CC> LD_LIBRARY_PATH,
  CC> now I'm set.  Thanks.

now you must learn not to not jeopardy quote. we will thank you for that.

  >> i think use PSI::ESP may come to the rescue. when he changed
  >> LD_LIBRARY_PATH for the shell it failed the same way. i am now divining
  >> that he forgot (or was never told) to put the standard lib paths in that
  >> var too! by default, libraries are searched for in usually just
  >> /usr/lib. if LD_LIBRARY_PATH is set, that is the list of dirs to search
  >> and the default is not searched. so set it to:

that is a damn fine module. if only i could find its author and thank
him? who is that masked perl hacker riding off into the sunset with only
a 900 number to remember him by? call 1-900-PSI-PERL to hear perl future
predictions and to have bugs fixed without any code being shown.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Mon, 22 Nov 1999 06:19:54 -0800
From: cautus <carrie.sullivanNOcaSPAM@colorspan.com.invalid>
Subject: Re: Error Using Access db Created in a Workgroup
Message-Id: <0e6f0358.aec40378@usw-ex0106-044.remarq.com>

I may not be understanding your dilema correctly, but it sounds like
you need to use the workgroup administrator to join the workgroup that
the database was created under or is looking for.  The default used
when a database is created is the system.mdw in your MSOffice
directory.  If nothing else, use the login Admin with no password.  I
think I have battled every workgroup/permissions battle that exists. 
There are some password cracking tools available if you really get
yourself in a bind and it is an Access workgroup related problem.


* 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: Mon, 22 Nov 1999 07:22:36 -0800
From: Bill Moseley <moseley@best.com>
Subject: Re: exists causes internal server errors!!
Message-Id: <MPG.12a2ff98a2b52d30989898@nntp1.ba.best.com>

Waranun Bunjongsat (bunjonwa@trek.CS.ORST.EDU) seems to say...
> Hi,
> 
> 	Now, I managed to get the dbmopen() works the db is not DB_File
> but it is something with *.dir and *.pag. Do not know what type of
> database because I use 'use AnyDBM_File;', and use
> dbmopen(%myhash,'filename', 0644); However when I do ...
> 
> $myquery = "myname";
> if(exists $myhash{$myquery}){
> ...
> }
> 
> 	It causes internal compilation error, Anyboby could tell me why ?

Maybe the 'exists' method isn't defined?






-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Mon, 22 Nov 1999 14:05:00 GMT
From: g0177325@my-deja.com
Subject: Re: file descriptors already used when perl starts
Message-Id: <81biia$uui$1@nnrp1.deja.com>

In article <813kir$t5l$1@pegasus.csx.cam.ac.uk>,
  mjtg@cus.cam.ac.uk (M.J.T. Guy) wrote:
> In article <811o2k$ata$1@nnrp1.deja.com>,  <g0177325@my-deja.com>
wrote:
> >Can anyone explain the following:
> >
> >  perl -e 'open A, ">&2"; open B, ">&2"; print fileno A, fileno B'
> >  37
> >
> >So, file descriptors 4,5,6 are somehow in use.  Why?
>
> As various others have remarked, they aren't for me.
>
> But I'll gaze into my crystal ball and guess that you're running on
> some flavour of Linux.    There is a bug in some versions of glibc
> that causes open to allocate a file descriptor other than the lowest
> available, explicitly contrary to POSIX and to Linux's own man page.

Not Linux, but AIX, which may be worse :-)  And it is definitely OS
dependent, not sloppy perl C code dependent as I slanderously alleged
before.  With perl5.004_04, AIX 4.3.1 gives the '37' result, but AIX
4.3.2 gives the '34' result.

I've said it before and I'll say it again: Good Ol' AIX!

And from Lee lindley's posts, apparently Solaris is afflicted too.

John.


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


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

Date: Mon, 22 Nov 1999 14:17:19 +0000
From: Reg Smith <rjsmith@uk.oracle.com>
Subject: FIXED:Re: Simple s#this string#that string# doesn't work?
Message-Id: <3839506F.338DBA47@uk.oracle.com>

Alex

Thanks for your reply - it got me to look at the rest of the script and
realize what I wasn't seeing right in front of my eyes.

There was another search and replace further down the script  to insert the
version in a history table;

s#<!-- CC_ID_STR -->.*?<!-- CC_ID_STR -->#$CC_ID_STR#s

This was picking up the same line already changed to what I'd intended and
changing it to just the version string. The last line in the script was just
a "print;", and I got the second version for both lines of the HTML file.

I had tested it in isolation and it worked, which is why I was scratching my
head at the apparent change in the bigger script. So now I've just got one
search and replace and it works just as advertized.

Thanks and apologies for being a dimwit.

Reg

rjsmith@uk.oracle.com

Alex Rhomberg wrote:

> Reg Smith wrote:
> >
> > What I have done is to surround the strings I want to replace with HTML
> > comment tags, to simplify searching for them. e.g.
> >
> > In the HTML file, there is a line like this;
> >
> > <!-- CC_ID_STR -->\main\work_in_progress\5<!-- CC_ID_STR -->
> >
> > s#<!-- CC_ID_STR -->.*?<!-- CC_ID_STR -->#<!-- CC_ID_STR
> > -->$CC_ID_STR<!-- CC_ID_STR -->#s;
> >
> > But what is actually happenning is that the <!-- CC_ID_STR --> tags are
> > not appearing in the new file at all, but the new version is;
> >
> > Line in OLD file
> > <!-- CC_ID_STR -->\main\work_in_progress\5<!-- CC_ID_STR -->
> >
> > Replaced line in NEW file
> > \main\work_in_progress\6
>
> Did you test what you posted?
> Just testing your code indicates to me that it is working correctly:
>
> $_ = '<!-- CC_ID_STR -->\main\work_in_progress\5<!-- CC_ID_STR -->';
> my $CC_ID_STR = "/main/work_in_progress/6";
>
> s[<!-- CC_ID_STR -->.*?<!-- CC_ID_STR -->]
>  [<!-- CC_ID_STR -->$CC_ID_STR<!-- CC_ID_STR -->]s;
> print "$_\n";
>
> prints the correct string.
>
> I'd change some stuff to shorten it and minimize the probability of
> typing errors:
>
> my $tag = qr#<!-- CC_ID_STR -->#;
>
> s#(?<=$tag).*?(?=$tag)#$CC_ID_STR#s;
>
> - Alex
> PS: cut your .sig by about 10 lines and a useless vcard

--





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

Date: Mon, 22 Nov 1999 14:37:26 GMT
From: "Jim Mosier" <jim.mosier@usa.net>
Subject: Re: Fork Children w/ Expect
Message-Id: <Gyc_3.7$QT2.3816@pm02news>

Thanks for the reply.  The actual code is below.

Tom Phoenix <rootbeer@redcat.com> wrote in message
news:Pine.GSO.4.10.9911201239050.16575-100000@user2.teleport.com...
| On Fri, 19 Nov 1999, Jim Mosier wrote:
|
| > The children will die but keep coming back.
|
| That sentence seems meaningless to me.

Not a good choice of words, sorry.  But the children seem to be forking new
children rather than dieing gracefully, but ONLY when I use Expect.
|
| > Since my parent is spawning a child which spawns a telnet, I'm
| > wondering if Perl is loosing it's mind.
|
| Could it be that somehow a child process is running the parent's code?
| That could happen if someone forgot to check that an exec succeeded,
| and it would probably make your program seriously confused.
|

I suspect it's likely at this point.  Any ideas or samples?  THANKS!

| Cheers!
|
| --
| Tom Phoenix       Perl Training and Hacking       Esperanto
| Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
|

#!/usr/local/bin/perl -w
use Expect;
my $custdir = "/my/data/directory";
my @customers = qw(one two three four);
my $allow = 10;   # how many children at once

# Install the handler to cope with the loss of a child
$SIG{CHLD} = \&lostchild;

# spawn the children
while( ( @customers > 0 ) && ( $children < $allow ) ) { spawn() }

# sit back and wait until all the customers have been popped off
while(@customers > 0) {sleep(10)}
print "handled all customers, $children children still alive\n";
exit;

sub spawn {
 $pid = fork; # spawn child; $pid==0 for child, !=0 for parent
 if($pid) {  # still in parent process
  $children++;
  $customer = shift @customers; # pop next customer off array
  print "spawned new child to handle $customer; now $children alive\n";
 }
else {   # in child process
  $customer = $customers[0]; # handle the next customer

      ###########################################
      # Grab a modem for this customer if needed
      ###########################################
        print "*** Grabbing a modem for $customer\n";
        $modem = Expect->spawn( "/bin/telnet 10.10.10.10. 9999" );
        if( $modem ) {
          print $modem "AT\r";
          $modem->expect( 5, "OK" );
          sleep(5);
        }

    # Close the connection to the modem if it was established.
    if( $modem ) { $modem->hard_close() }

  # kill this process; use 'exit' for no output
  die("child process finished dealing with $customer\n");
 }
}

sub lostchild {
 $children--;
 print "lost a child! $children children left. still need ${\scalar
@customers} more.\n";
 if(@customers > 0) {spawn()}
}




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

Date: Mon, 22 Nov 1999 16:23:55 GMT
From: lin.minnich@usa.net (Linda Minnich)
Subject: FTP in PERL, cmd line args etc.
Message-Id: <38396cbc.11939239@nntp.lucent.com>

Before implementing any code, I want to visualize how I am going to do
this:

the problem:  Called from another piece of code - written in a
different language - this perl script should ftp a file to a server.


the solution:  I plan on having the Perl code accept a list of
arguments.. that being the servername to FTP to, a login name, passwd,
and the filename to be uploaded.  Then the Perl code will put this
file into a different server.

Is this even possible? I found a perl module that does NET::FTP where
you can use FTP.  But I cannot figure out how to pass a parameter from
my code to the Perl code.  I was thinking of just calling a system
call in unix but : Can you accept command line arguments into Perl
like you can with C code?  par example in C: 
                    main(int argc, char **argv){ }

I tried looking on all FAQS and I searched the www.perl.com
documentation but I can't find any good examples.  All I need is some
sample code of implementing this. If you can help I'll be a super
happy girl!!!!
Thanx a bunch,
Linda


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

Date: Mon, 22 Nov 1999 13:05:07 GMT
From: che@worker.com (Adam Levenstein)
Subject: Re: Help w/ DBI
Message-Id: <38393f39.402690722@news.psu.edu>

On 22 Nov 1999 10:02:49 GMT, Jonathan Stowe <gellyfish@gellyfish.com>
wrote:

>Well if you dont know what they are for leave them out - that still leaves
>the unwanted single quotes and the fact that you left all the string values
>unquotes (necesaary in SQL) - I really do recommend that you take my advice
>about checking the success of the do() and printing the error.

I'd love to, but the script doesn't get far enough to actually do it.
My top lines, as per Abigail's advice, are:

#/usr/bin/perl -wT

use DBI
use CGI;
use strict;

Did I goof something? I think the problem is here.

Adam


------------------------------------------------------
"You must be in love with the devil.  You probably 
sold your soul to him to learn how to play the banjo.
May God help you!"

              - "Bishop" Norman Boyd


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

Date: 22 Nov 1999 13:35:01 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Help w/ DBI
Message-Id: <38394685_2@newsread3.dircon.co.uk>

Adam Levenstein <che@worker.com> wrote:
> On 22 Nov 1999 10:02:49 GMT, Jonathan Stowe <gellyfish@gellyfish.com>
> wrote:
> 
>>Well if you dont know what they are for leave them out - that still leaves
>>the unwanted single quotes and the fact that you left all the string values
>>unquotes (necesaary in SQL) - I really do recommend that you take my advice
>>about checking the success of the do() and printing the error.
> 
> I'd love to, but the script doesn't get far enough to actually do it.
> My top lines, as per Abigail's advice, are:
> 
> #/usr/bin/perl -wT
> 
> use DBI

You're missing a ; above

> use CGI;
> use strict;
> 

This is a separate issue - you will need to run the program from the
command line and sort out the problems that 'strict' throws up - you
will also need to read the CGI.pm manpage to find out how to convert
to using that module rather than the homegrown thing.

> Did I goof something? I think the problem is here.
> 

Make a short cut-down non-CGI program that you can run from the
commandline that only does the DBI stuff and get your INSERT right
there.

/J\
-- 
"I thought homogenous culture was a kind of yogurt used to alleviate
thrush" - Ben Elton


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

Date: Mon, 22 Nov 1999 14:02:24 GMT
From: marius_13@my-deja.com
Subject: Help with TCP sockets please
Message-Id: <81bidf$ut6$1@nnrp1.deja.com>

I am trying to modify a small TCP example to work for my needs.  I am
trying to do some basic TX/RX to better understand the syntax.  I am
trying to send a couple of msgs between a client and a server.  The
problem is that I connected, but am having reading problems, it appears
to be on the server side.  I am using 1 socket for 2-way traffic, any
problems with that???  Thanks for all help.  Also, I didn't see any FAQ
topics that covered this.  If I missed it, please let me know where
they are.   Code snipet below:


SERVER:
===========================================
$paddr = accept(Client,Server);
$done = 0;
print "msg 1\n";                   <---- Printed during running
while (!$done)
{
print "msg 2\n";                   <---- Printed during runningg
  $msg = <$paddr>;
  print "got msg\n";               <---- not printed
  print $msg;

  print Client "Message received: [", $msg, "]\n";
  if ($msg == "close")
  {
    $done = 1;
  }
}


CLIENT:
=======================================
socket(SOCK, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
connect (SOCK, $paddr)                     or die "connect: $!";
   print "msg 1\n";             <--- Printed
   print SOCK "Hello\n";
   print "msg 2\n";             <--- Printed
   $msg = <SOCK>;
   print "msg 3\n";             <--- Not printed
   print $msg;
   print "msg 4\n";

   print SOCK "World\n";
   $msg = <SOCK>;
   print $msg;

   print SOCK "exit";
   $msg = <SOCK>;
   print $msg;



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


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

Date: Mon, 22 Nov 1999 12:30:02 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: How to create file in other directory ?
Message-Id: <slrn83iccc.koj.*@dragons.duesouth.net>

Once upon a time (21 Nov 1999 22:38:48 -0600), Abigail) was attempting
to figure out Ilya's new Perl regex features, and accidently sent the
following to comp.lang.perl.misc: 
:        s/foo|bar|baz/"is_$&"->()/eg while<>;
:
: Perl golf anyone?

         s/foo|bar|baz/&{"is_$&"}/eg while<>;

Hmm, those aren't quite the same, though.
         
: Abigail

--Matthew


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

Date: Mon, 22 Nov 1999 15:17:23 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: How write records to ASCII file
Message-Id: <slrn83inop.1l0.bmccoy@moebius.foiservices.com>

Also Sprach Al Franz <albert@netmation.com>:

>Are there public domain perl scripts to write data and/or retrieve data
>from ascii files?

You mean aside from the fact that this is one of the most basic
functionalities in Perl, and is the very first example used in the Camel
Book?

-- 
Brett W. McCoy                             bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek)   http://www.foiservices.com
FOI Services, Inc./DIOGENES                301-975-0110
---------------------------------------------------------------------------


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

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


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