[18478] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 646 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 7 03:05:52 2001

Date: Sat, 7 Apr 2001 00:05:16 -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: <986627116-v10-i646@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 7 Apr 2001     Volume: 10 Number: 646

Today's topics:
    Re: Anyone know how to handle CVS files With " in them? (Martien Verbruggen)
    Re: bare block usage (Abigail)
        complaint about moderation of this group <hhsoft@csoft.net>
    Re: complaint about moderation of this group <uri@sysarch.com>
    Re: cookie woes. <hhsoft@csoft.net>
    Re: Copying Directories (David Efflandt)
    Re: Copying Directories (David Efflandt)
        Database queries from a web browser Questions.... <NOSPAM@netzero.net>
    Re: deleting files <bigusAT@btinternetDOT.com>
    Re: Does "return @list" do a copy? <persicom@acedsl.com>
        HTML/PERL WWW Statistics <philip@p6m7g82k.student.umd.edu>
        inheritance within one file? <prlawrence@lehigh.edu>
    Re: inheritance within one file? (Logan Shaw)
    Re: inheritance within one file? <uri@sysarch.com>
        newbie help - replace <P> tags only if within <DIR> tag <jpvdv@hotmail.com>
    Re: newbie help - replace <P> tags only if within <DIR> <juex@my-deja.com>
    Re: password encryption (Craig Berry)
    Re: password encryption nobull@mail.com
        pattern match\substitution <bmccann@naisp.net>
    Re: pattern match\substitution (Logan Shaw)
        Perl + SFTP method? <smilepak@hotmail.com>
        Perl-ish regexp and pattern match in C/C++ ? <mitiaNOSPAM@northwestern.edu.invalid>
    Re: Perl-ish regexp and pattern match in C/C++ ? <aqumsieh@hyperchip.com>
    Re: print() and die() with multiple filehandles? Loggin <aqumsieh@hyperchip.com>
    Re: Question about refcounting nobull@mail.com
        Regexp & function? <NO_SPAM_klubbheads@home.com>
    Re: Regexp & function? (Craig Berry)
    Re: Reverse DNS Lookup (David Efflandt)
        time difference 2  <Waarddebon@chello.nl>
        Using perl in an NT logon script <jlkeith@bellsouth.net>
    Re: what are the new languages? <mitiaNOSPAM@northwestern.edu.invalid>
        Why Perl? (GrapeApe)
    Re: Why Perl? <mitiaNOSPAM@northwestern.edu.invalid>
        Win32 fork() hangs - activestate perl build 623 <nverenin@san.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 7 Apr 2001 10:09:23 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Anyone know how to handle CVS files With " in them?
Message-Id: <slrn9csmlj.3ud.mgjv@martien.heliotrope.home>

On Fri, 6 Apr 2001 12:44:54 -0400 ,
	Steve Alpert <Steve_Alpert@idx.com> wrote:
> "Gary Blake" <gary@tigerstripes.co.uk> wrote:
> 
>>Anyone know how to handle CVS files With " in them?
>>
>>I've come up blank with google searches!
>>
>>Gary
> 
> my @temp = ();
> push(@temp, $+) while m{ "([^"]*)",?|([^,]+)|,}gx;

Try this on the line:

"aa","b""c",dd

which is a CSV formatted line with three fields:

@temp = qw(aa b"c dd);

Your solution incorrectly makes it

@temp = qw(aa b c dd);

Besides that, a line like:

1,2,3

which is valid CSV, ends up being

@temp = (1, undef, 2, undef, 3);

If you want to answer a question which is specifically about _correctly_
handling quotes inside CSV files, you should probably make sure that you
test your solution on some real valid CSV data.

Hopefully the OP has already done what I suggested earlier, and used
search.cpan.org to find one of the modules that deal with all this.
While it is possible to do this yourself, with loads of work, why would
you?

Martien
-- 
Martien Verbruggen              | My friend has a baby. I'm writing
Interactive Media Division      | down all the noises the baby makes so
Commercial Dynamics Pty. Ltd.   | later I can ask him what he meant -
NSW, Australia                  | Steven Wright


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

Date: Fri, 6 Apr 2001 22:36:45 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: bare block usage
Message-Id: <slrn9csh7t.kpv.abigail@tsathoggua.rlyeh.net>

Tad McClellan (tadmc@augustmail.com) wrote on MMDCCLXXV September
MCMXCIII in <URL:news:slrn9cs7u0.ms9.tadmc@tadmc26.august.net>:
== Cosmic Cruizer <c_cruizer@my-deja.com_nospam> wrote:
== >I've been reading up on using bare block statements and I have to question 
== >it's redundant use. It seems to me that using either do-while or do-until 
== >would be much clearer when it comes to reading the code. I've been looking 
== >through examples of code, but have not seen any that uses bare blocks.
== 
== 
==    { local $/;  $_ = <> }    # slurp the entire file(s)
== 
== 
== >My questions: Does anybody here use bare blocks 
== 
== 
== Yes.
== 
== 
== >and why? 
== 
== 
== To control variable scope.
== 
== 
== >Is there a 
== >specific situation where bare blocks might be better then using a do-while 
== >or do-until? 
== 
== 
== How about when you don't want or need any looping?
== 
== 
== >Any other benefits or drawbacks?
== 
== 
== It saves typing 3 characters (a profoundly silly "benefit").


Yeah, but I find bare blocks excellent looping constructs. for (;;) and
while () are actually limited case; they check termination conditions
at only one point. You can bail out with last of course, but then you
might as well use a bare block.

I seldomly write "while (1) {BLOCK}", I prefer "{BLOCK; redo}".


Abigail


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

Date: Sat, 07 Apr 2001 01:17:18 -0500
From: Kyle Dusang <hhsoft@csoft.net>
Subject: complaint about moderation of this group
Message-Id: <rebtct88mrc1frc42v8r21hpa32su5itbr@4ax.com>

To whom it may concern: I was under the (perhaps mistaken) impression
that usenet was a forum in which to exchange information and for
novices to be able to ask questions and for those more experienced or
knowledgable to answer said questions if they so desire. I was also
under the impression that Perl was a programming language that was
used to create web applications. Sorry if this isn't as eloquently
stated as I'd like it to be....but every time I ask a question in this
group, one which concerns a PERL script I am working on...some anal
retentive moderator tells me its off topic and that it doesn't deal
specifically with PERL....(but it DOES dangit!) and probably kill
filters me or something...(whatever the heck that means)...preventing
anyone else who IS interested in helping from being able to offer
help. Lighten up a little....GEEZ.....i'm not posting spam or ads for
porno sites or anything. By the way...this group is perl.misc, right?
That means even if the question does concern another technology which
is referenced from a perl script...it should be allowed...and i'm sure
twenty or more people knew the answer to my question and could have
lended a hand if they chose to. I'm not trying to "look a gift horse
in the mouth" but gee wiz...I will not ask any questions in this group
anymore...i found the answer to my question on the web....where i will
go from now on...so don't bother reply to this (except via email if u
want) because i will not point my reader to this group any more...you
(the moderators) are not cool. Good bye.


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

Date: Sat, 07 Apr 2001 06:26:50 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: complaint about moderation of this group
Message-Id: <x77l0xrzro.fsf@home.sysarch.com>

>>>>> "KD" == Kyle Dusang <hhsoft@csoft.net> writes:

  KD> specifically with PERL....(but it DOES dangit!) and probably kill

the language is Perl, the program is perl. there is no such thing as PERL

  KD> That means even if the question does concern another technology
  KD> which is referenced from a perl script...it should be
  KD> allowed...and i'm sure

BZZZZT! wrong. please try again. if i use perl to write a recipe
program, am i allowed to ask about how to saute here? if anything
possibly done with perl is on topic, then tell me what is off topic?
perl can be used to program anything.

  KD> twenty or more people knew the answer to my question and could
  KD> have lended a hand if they chose to. I'm not trying to "look a
  KD> gift horse in the mouth" but gee wiz...I will not ask any
  KD> questions in this group anymore...i found the answer to my
  KD> question on the web....where i will go from now on...so don't

good. that is what you should have done in the first place. this is NOT
a help desk but a discussion group on the language Perl. searching the
web for an answer is much better in most cases. there are plenty of perl
web sites out there. if you want to discuss a point of the perl language
you can come here. you don't seem to understand the difference.

  KD> bother reply to this (except via email if u want) because i will
  KD> not point my reader to this group any more...you (the moderators)
  KD> are not cool. Good bye.

this is not a moderated group. but you won't know that since you
unsubscribed.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Fri, 06 Apr 2001 17:29:56 -0500
From: Kyle Dusang <hhsoft@csoft.net>
Subject: Re: cookie woes.
Message-Id: <cqgsctg93j1rqlde2ks2v4bdect88s87l4@4ax.com>


Ummmm...maybe because it's a line from a PERL SCRIPT

On Fri, 6 Apr 2001 20:24:51 +0000 (UTC), abigail@foad.org (Abigail)
wrote:

>Kyle Dusang (hhsoft@csoft.net) wrote on MMDCCLXXV September MCMXCIII in
><URL:news:319qctkt92tvrqano5lriemtiv039jiebu@4ax.com>:
>$$ Any reason why the following would not set a cookie in netscape 4.7
>$$ which lasts longer than a browser session? (it does in I.E. 5)
>$$ 
>$$ print "Set-Cookie: rpassword=${password}; expires=Thu, 01-Jan-2099
>$$ 00:00:00 GMT;\n";
>
>
>
>What makes you think this is a Perl question? 
>
>
>Abigail



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

Date: Sat, 7 Apr 2001 02:34:22 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Copying Directories
Message-Id: <slrn9csv5q.m7.efflandt@efflandt.xnet.com>

On Fri, 6 Apr 2001 14:39:49 GMT, Phil Shean <philip.shean@uwe.ac.uk> wrote:
>
>Is it possible to copy a directory complete with all it's contents (inc
>sub-dirs)?

perldoc -f rename

Works like mv or move (or rename in ftp).

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Sat, 7 Apr 2001 02:37:02 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Copying Directories
Message-Id: <slrn9csvar.m7.efflandt@efflandt.xnet.com>

On Sat, 7 Apr 2001 02:34:22, David Efflandt <efflandt@xnet.com> wrote:
>On Fri, 6 Apr 2001 14:39:49 GMT, Phil Shean <philip.shean@uwe.ac.uk> wrote:
>>
>>Is it possible to copy a directory complete with all it's contents (inc
>>sub-dirs)?
>
>perldoc -f rename
>
>Works like mv or move (or rename in ftp).

Oops!  Forget that, thought it was like earlier question about moving
a dir.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Fri, 6 Apr 2001 21:52:28 -0500
From: "RJ" <NOSPAM@netzero.net>
Subject: Database queries from a web browser Questions....
Message-Id: <9alvia$6eh$1@news.tamu.edu>

I have to have access to an Oracle database from a web browser through a
server (as the middleman). The user will be inputting data that will be
searched for in the database, no other requirements are necessary from the
web browser (such as deleting tables, etc., just queries). What is the best
way to handle this for someone who only knows how to build the database? I
have heard of CGI's and the like, but I am unfamiliar with it. Are there any
good sources of code out there? Thanks for any help...

RJ




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

Date: Sat, 7 Apr 2001 01:23:50 +0100
From: "S Warhurst" <bigusAT@btinternetDOT.com>
Subject: Re: deleting files
Message-Id: <9almb4$rog$1@plutonium.btinternet.com>

This is a multi-part message in MIME format.

------=_NextPart_000_0026_01C0BF01.667CC7A0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Wont...

unlink "drive:/folder/file.ext";

 ...do the trick?
  "T_Boss" <T_boss75@curanet.com> wrote in message =
news:pMoz6.130896$lj4.3976867@news6.giganews.com...
  How can I delete files that are not in the same directory as the perl =
script
  =20
  =20

------=_NextPart_000_0026_01C0BF01.667CC7A0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3103.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Wont...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>unlink =
"drive:/folder/file.ext";</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>...do the trick?</FONT></DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
  <DIV>"T_Boss" &lt;<A=20
  href=3D"mailto:T_boss75@curanet.com">T_boss75@curanet.com</A>&gt; =
wrote in=20
  message <A=20
  =
href=3D"news:pMoz6.130896$lj4.3976867@news6.giganews.com">news:pMoz6.1308=
96$lj4.3976867@news6.giganews.com</A>...</DIV>
  <DIV><FONT face=3DArial size=3D2>How can I delete files that are not =
in the same=20
  directory as the perl script</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial =
size=3D2></FONT>&nbsp;</DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0026_01C0BF01.667CC7A0--



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

Date: Fri, 06 Apr 2001 19:47:25 -0400
From: "Matthew O. Persico" <persicom@acedsl.com>
Subject: Re: Does "return @list" do a copy?
Message-Id: <3ACE558D.863F83B2@acedsl.com>

Jeff Pinyan wrote:
> 
> On Apr 5, Matthew O. Persico said:
> 
> >Because TIMTOWTDI in Perl. :-). Seriously, I think that references were
> >added in version 5; prior to that you HAD to get the copy. In order not
> >to break older code, the original copy sematics were not removed.
> 
> Before references, you could use typeglobs, which allowed aliasing:
> 
>   sub makeBigHash_1 {
>     local %hash = ( ... );
>     return *hash;
>   }
> 
>   sub makeBigHash_2 {
>     local *hash = @_;
>     %hash = ( ... );
>   }
> 
> They are called like so:
> 
>   *alias_to_hash = makeBigHash_1();
>   makeBigHash_2(*alias_to_hash);
> 
> They're the Perl 4 way of doing things.  No need for such tomfoolery
> anymore.

Duh, You're right. But, maybe not "duh" - I'm a late bloomer. I didn't
start using perl until 1997, understanding it in 1998.

-- 
Matthew O. Persico
    
http://www.acecape.com/dsl
AceDSL:The best ADSL in Verizon area


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

Date: 6 Apr 2001 22:30:36 GMT
From: "Philip M. Gollucci" <philip@p6m7g82k.student.umd.edu>
Subject: HTML/PERL WWW Statistics
Message-Id: <9alg2c$fi8$1@hecate.umd.edu>

I have a page stats.cgi which takes the resolution from a Java Script1.2 in 
in resolution.cgi.  Along with this information, it keeps percentages on the Browser,
Date, Time, OS, Language, and Resolution.  My first one works.  The problem is that I am the
only person that can understand it.  Does anyone know of any SOURCE CODE examples that do this ?


- 
*****************************************************************************
Philip M. Gollucci (p6m7g8)
Web-site    : http://www.p6m7g8.com
E-mail      : gollucci@wam.umd.edu 
	      Philip@p6m7g8.com 
Phone       : 301.249.6261 (Home)
	      301.314.3118 (College)
Major       : Computer Science 
Minor	    : Classical & Jazz Performance
Current Job : Science, Discovery, & the Universe Webmaster
	      URL: http://www.sdu.umd.edu 
Resume	    : http://www.wam.umd.edu/~gollucci/resume.html
*****************************************************************************



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

Date: Sat, 7 Apr 2001 00:05:59 -0700
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: inheritance within one file?
Message-Id: <9am3hi$k14@fidoii.CC.Lehigh.EDU>

While hacking together a set of 2 modules and a script to test out
some inheritance issues, I thought, "Why not stick this all into one
file for convenience?"

However, the following won't work because there is no A.pm module on
my system.  Is it possible to inherit methods from packages within the
same script?  I'm guessing not...
----------------------------
#!../../perl
package A;
sub foo {
    my $proto = shift;
    my $class = ref($proto) || $proto;
    my $self = {};
    bless ($self,$class);
    return $self;
}

package B;
# Obviously the wrong mechanism ->
use vars qw( @ISA );
@ISA = qw ( A );
use A;
# <-

sub new {
    # I want to inherit A's foo method!
    my $b = $self->foo;
}

package main;
my $b = B->new;
----------------------------

Thanks,
Phil R Lawrence




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

Date: 6 Apr 2001 23:34:55 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: inheritance within one file?
Message-Id: <9am5df$nb$1@boomer.cs.utexas.edu>

In article <9am3hi$k14@fidoii.CC.Lehigh.EDU>,
Phil R Lawrence <prlawrence@lehigh.edu> wrote:
>However, the following won't work because there is no A.pm module on
>my system.  Is it possible to inherit methods from packages within the
>same script?  I'm guessing not...
>----------------------------
>#!../../perl
>package A;
>sub foo {
>    my $proto = shift;
>    my $class = ref($proto) || $proto;
>    my $self = {};
>    bless ($self,$class);
>    return $self;
>}
>
>package B;
># Obviously the wrong mechanism ->
>use vars qw( @ISA );
>@ISA = qw ( A );
>use A;
># <-
>
>sub new {
>    # I want to inherit A's foo method!
>    my $b = $self->foo;
>}
>
>package main;
>my $b = B->new;
>----------------------------

This doesn't work because "use" is like "require" followed by "import",
and "require" reads from a file on disk.

What you must do to make is to skip the "require" phase of the "use".

In your case, you can do this by changing the "use A;" to "import A;".
Actually, in your case, "A" doesn't export anything, so you don't care,
but if it did, then you'd have to do that.

Note that, normally, the dependencies between scripts are handled
automatically because (according to "perldoc -f use", which by the way
is a good thing to read) coding "use" is really alot like coding this:

	BEGIN
	{
		require A;
		import A;	# or "import A qw{ foo bar };"
	}

This means that whenever a module "use"s another module, any modules it
"use"s will get compiled *before* it, thus ensuring it has all the
stuff it needs to compile correctly.  But, if you're putting all of the
modules in one big file together, then they're going to get defined in
the order they appear in the file.

This just means you have to put them in the right order.  (Luckily, a
partial ordering isn't as strict a requirement as a full ordering, so
there will always be a right order to put them in.  It's just that you
may have to figure it out for yourself, whereas the interpreter was
doing that for you before.)

  - Logan
-- 
whose?  my  your   his  her   our   their   _its_
who's?  I'm you're he's she's we're they're _it's_


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

Date: Sat, 07 Apr 2001 04:41:28 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: inheritance within one file?
Message-Id: <x7ae5ts4na.fsf@home.sysarch.com>

>>>>> "LS" == Logan Shaw <logan@cs.utexas.edu> writes:

  LS> In article <9am3hi$k14@fidoii.CC.Lehigh.EDU>,
  LS> Phil R Lawrence <prlawrence@lehigh.edu> wrote:
  >> package A;
  >> sub foo {
  >> my $proto = shift;
  >> my $class = ref($proto) || $proto;
  >> my $self = {};
  >> bless ($self,$class);
  >> return $self;
  >> }
  >> 
  >> package B;
  >> # Obviously the wrong mechanism ->
  >> use vars qw( @ISA );
  >> @ISA = qw ( A );
  >> use A;

  >> sub new {
  >> # I want to inherit A's foo method!
  >> my $b = $self->foo;
  >> }
  >> 
  >> package main;
  >> my $b = B->new;
  >> ----------------------------

  LS> This doesn't work because "use" is like "require" followed by
  LS> "import", and "require" reads from a file on disk.

but he is using object calls, not imported subs. so that has no bearing
on his problem. the use call is useless here as it doesn't load any code
and probably will bomb as A.pm won't be found.

from a quick glance at it, it should work fine if the use call is
deleted. he sets up the @ISA before the B->new() call is made.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Sat, 07 Apr 2001 06:41:24 GMT
From: "JP" <jpvdv@hotmail.com>
Subject: newbie help - replace <P> tags only if within <DIR> tags
Message-Id: <oEyz6.20033$BU4.33535@news1.blktn1.nsw.optushome.com.au>

Hi, i'm just starting out with perl. I am writing a program which replaces
<P> and </P> tags with <LI> and </LI> only if they are within <DIR> tags
any <P>s outside need to be unchanged.

I have put the whole file into a string but cannot figure out how to only
replace the <P>s if they are within <DIR> and </DIR>

is there some kind of way I can do this with a for loop? or is it easier to
do it in a regex?

thanks in advance.




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

Date: Fri, 6 Apr 2001 23:53:54 -0700
From: "Jürgen Exner" <juex@my-deja.com>
Subject: Re: newbie help - replace <P> tags only if within <DIR> tags
Message-Id: <3aceb98a$1@news.microsoft.com>

"JP" <jpvdv@hotmail.com> wrote in message
news:oEyz6.20033$BU4.33535@news1.blktn1.nsw.optushome.com.au...
> Hi, i'm just starting out with perl. I am writing a program which replaces
> <P> and </P> tags with <LI> and </LI> only if they are within <DIR> tags
> any <P>s outside need to be unchanged.
>
> I have put the whole file into a string but cannot figure out how to only
> replace the <P>s if they are within <DIR> and </DIR>
>
> is there some kind of way I can do this with a for loop? or is it easier
to
> do it in a regex?

Use HTML::Parser.
RegExp's are not powerful enough and creating your own parser is not only
re-inventing the wheel but also very error prone (unless of course you are
holding a Ph.D. in compiler construction).

jue




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

Date: Fri, 06 Apr 2001 22:56:07 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: password encryption
Message-Id: <tcsic754ruvof1@corp.supernews.com>

Steven Smolinski (sjs@linux.ca) wrote:
: Simon Stiefel <SiStie@nuclear-network.com> wrote:
: > I have to transmit a password with the "get"-function to my CGI-Script (so
: > it can be seen by everyone).
: > 
: > What is the easiest way to encrypt and decrypt the password?
[snip]
: Rather than encrypting and decrypting the password (symmetric ciphers
: require you to solve the key distribution problem anyway), could you not
: use web services set up to solve this problem already, like SSL?  Once
: you have a secure channel, send the passowrd in plaintext.

The OP specified GET rather than POST, and GET params are not protected by
SSL (they can't be, as they are appended to the URL itself).  Your
proposed solution is the right thing to do, iff he can use POST instead.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "When the going gets weird, the weird turn pro."
   |               - Hunter S. Thompson


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

Date: 07 Apr 2001 07:46:17 +0100
From: nobull@mail.com
Subject: Re: password encryption
Message-Id: <u9wv8xus06.fsf@wcl-l.bham.ac.uk>

cberry@cinenet.net (Craig Berry) writes:

> Steven Smolinski (sjs@linux.ca) wrote:
> : Simon Stiefel <SiStie@nuclear-network.com> wrote:
> : > I have to transmit a password with the "get"-function to my CGI-Script (so
> : > it can be seen by everyone).
> : > 
> : > What is the easiest way to encrypt and decrypt the password?
> [snip]
> : Rather than encrypting and decrypting the password (symmetric ciphers
> : require you to solve the key distribution problem anyway), could you not
> : use web services set up to solve this problem already, like SSL?  Once
> : you have a secure channel, send the passowrd in plaintext.
> 
> The OP specified GET rather than POST, and GET params are not protected by
> SSL (they can't be, as they are appended to the URL itself).

They are still protected in transit by SSL, they are visible to the user.

> Your proposed solution is the right thing to do, iff he can use POST instead.

Using POST rather than get only prevents the user accidentally seeing
the password.  If they users want to see the password they can view
source.

This, of course, has nothing to do with Perl.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Sat, 7 Apr 2001 01:21:16 -0400
From: "Brian McCann" <bmccann@naisp.net>
Subject: pattern match\substitution
Message-Id: <tct5m0e4guvqce@corp.supernews.com>

Hi,

I wrote this script to search for the string "tag" in the file (I know there
will always bee just one
instance of the string"tag") in WhatLable.java and replace "tag" with the
value of
$tag, two questions, when I run the script on the command line it makes
the substitution in the dos window but the file remains unchanged. What am I
doing wrong?
tia,
Brian


open( TAG,
"+<C:\\$dir\\$tag\\source\\Applications\\InternalProduct\\Java\\Utils\\WhatL
abel.java" ) or die( "Cannot open file :$!" );
while ( <TAG> ) {
   if (m/tag/) {
      s/tag/$tag/;
      print( TAG );
   }

   #print( "file: $_\n" );

}
close( TAG ) or die( "Cannot close file : $!");





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

Date: 6 Apr 2001 23:56:23 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: pattern match\substitution
Message-Id: <9am6ln$s7$1@boomer.cs.utexas.edu>

In article <tct5m0e4guvqce@corp.supernews.com>,
Brian McCann <bmccann@naisp.net> wrote:
>$tag, two questions, when I run the script on the command line it makes
>the substitution in the dos window but the file remains unchanged. What am I
>doing wrong?
>
>
>open( TAG,
>"+<C:\\$dir\\$tag\\source\\Applications\\InternalProduct\\Java\\Utils\\WhatL
>abel.java" ) or die( "Cannot open file :$!" );
>while ( <TAG> ) {
>   if (m/tag/) {
>      s/tag/$tag/;
>      print( TAG );
>   }
>
>   #print( "file: $_\n" );
>
>}
>close( TAG ) or die( "Cannot close file : $!");

One thing you're doing wrong is that you're assuming you can just read
and write from a file in any old order and somehow something else will
take care of not clobbering the data for you.

Basically, the way I/O normally works is that the operating system
keeps a file position for you when you open a file.  Usually, that
position is initialized to the beginning of the file when you start
reading, but it could be initialized to the end of the file instead, if
you open the file the right way.  Anyway, if you make a request to read
or write, the operating system reads or writes some number of bytes and
then advances the file position forward by that number of bytes.

Every time Perl runs "<TAG>" and reads a line from the file, it's going
to advance the file position by the amount read.  If you print in the
middle of the loop there, what's going to happen?  Well, the file
position will be the byte immediately *after* the end of the line you
just read.  So, if you write to the file at that point, you'll write
some number of bytes over the next line and then advance the file
position.

What's the subsequent read going to do?  It's going to pick up where
the write left off, which could be somewhere in the middle of the line
after the one that was previously read, or could be somewhere later in
the file if you wrote out enough data.

So basically, to do what you want to accomplish, the easiest way is to
write out a while different file.  That's because updating a file in
place is a real pain.  A file is just an ordered sequence of bytes, and
if you need to replace a 50 byte string with a 62 byte string, then
you're either going to overwrite 12 bytes, or you've got to shift all
the following bytes by 12.

For one-liners, Perl provides a way to have a temporary file created
for you automatically.  You just use the "-i" switch.  For more info on
that, do a "perldoc perlrun".

For longer scripts, just do something like this:

	$filename = "foo";
	rename $filename, "$filename.bak" or die "$!";

	open (ORIGINAL, "$filename.bak") or die "$!";
	open (NEW, ">$filename") or die "$!";
	while (<ORIGINAL>)
	{
		s/foo/bar/;
		print NEW $_;
	}
	close NEW;
	close ORIGINAL;

Hope that helps.

  - Logan
-- 
whose?  my  your   his  her   our   their   _its_
who's?  I'm you're he's she's we're they're _it's_


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

Date: Fri, 06 Apr 2001 22:56:21 GMT
From: "smilepak" <smilepak@hotmail.com>
Subject: Perl + SFTP method?
Message-Id: <pQrz6.10348$Kr1.871431@newsread1.prod.itd.earthlink.net>

I have a question, anyone know how to create a pl script that does sftp pull
from a remote site.

For Example:

username: user
password: pass
sftp address: sftp.mydomain.com
directory: /pub/mydir/
file: filename$date.txt

How am I suppose to do an FTP connection via script and provide the
username/password with it prompt
for it?

Haven't done this before so not sure on how to do it. Oh the basic perl
scripting, I already know how.
Just unsure how to structure the FTP command to provide the
username/password and path and get when
it ask for it.

Thanx
KN





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

Date: Fri, 06 Apr 2001 22:54:57 -0600
From: Dmitry Epstein <mitiaNOSPAM@northwestern.edu.invalid>
Subject: Perl-ish regexp and pattern match in C/C++ ?
Message-Id: <3ACE9DA1.DD0EA661@northwestern.edu.invalid>

I knew some C/C++ before I learned Perl, and used it for all my
programming needs.  But after I learned the wonderful Perl - a lazy
person's language - I am reluctant to return to C.  However, there are
times when I need to produce an executable, or when Perl just doesn't
cut it.  My question is, is there an implementation of Perl-like pattern
matching functions for C++?  (I am learning Visual C++ now.)

-- 
Dmitry Epstein
Northwestern University, Evanston, IL.  USA
mitia(at)northwestern(dot)edu


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

Date: Sat, 07 Apr 2001 06:07:27 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Perl-ish regexp and pattern match in C/C++ ?
Message-Id: <m3elv56xwq.fsf@alquds.qumsieh.homeip.net>


>          My question is, is there an implementation of Perl-like pattern
> matching functions for C++?  (I am learning Visual C++ now.)

I might not be the best person to answer this question , but I will
anyway :)

I believe there are regexp C++ classes as part of the STL. But I never
used those. However, I came across the wonderful Qt library
(www.trolltech.com) which is a graphical C++ library that contains lots
of useful classes including regexps, strings and hashes. KDE is written
using Qt.

my $0.02;

--Ala



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

Date: Sat, 07 Apr 2001 03:46:54 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: print() and die() with multiple filehandles? Logging of printed data?
Message-Id: <m3lmpds72p.fsf@alquds.qumsieh.homeip.net>


> Is there a way to tie multiple filehandles to one name so that all
> output goes to both stdout and a log file?

Checkout perlfaq5:

	How do I dup() a filehandle in Perl?

> What about the die function,
> which doesn't even take a filehandle argument?

die() outputs its messages to STDERR, so you can dup() that to arrange
for the messages to go to some log file.

Alternatively, you can arrange to capture all calls to die() by setting
the $SIG{__DIE__} handler to some function that prints to a file before
dying. Check out perlfunc's entry on die() and perlvar's entry on %SIG.

> Is there maybe a UNIX tool that I can invoke that records all the
> proceedings?

Yep. Look at tee().

--Ala


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

Date: 07 Apr 2001 07:37:16 +0100
From: nobull@mail.com
Subject: Re: Question about refcounting
Message-Id: <u9zodtuse5.fsf@wcl-l.bham.ac.uk>

"Richard B. Kreckel" <Richard.Kreckel@Uni-Mainz.DE> writes:

> 4       my $e1 = "x";
> 5       my $e2 = "y";

> 7       $e1 = \$e2;
> 8       $e2 = \$e1;
 
> I have seen some implementations of reference counting, but I am
> having some trouble understanding what is going on in Perl.  Could
> anybody with expertise in Perl's internals please enlighten me?

There are more levels of referencing going on internally inside perl
than you, the perl programmer, should ever need to worry about.  A
shallow understanding of the internals will actually make it harder to
understand what's going on.

The strings "x" and "y" in your example are red-herrings and just
complicate things.

> In line 4 and 5 we declare two variables. 

Actually you declare (compile time) and assign (run time).

> After that, "x" and "y" should have refcount==1.

Please disregard the strings they only complicate matters.

After line 5 both the scalars that hold the contents of the variables
have a refcount of one.

> In lines 7 and 8 we do stuff to $e1 and $e2,
> after which "x" and "y" aren't referenced any more and can be
> destroyed.  Is this correct?

This is not relevant.  The answer depends on optomisations which
cannot matter at the Perl programmer level. 

>  And then we have increaded the refcounts
> of $e2 and $e1 both from one to two and they drop to one again when
> they leave the scope leaving that circular reference.

Yes fine.  Leave it at that. 

>  Now I am confused.  Is there a reference count variable both for
> "x" and for $e1?

Why do you care? The answer to this question cannot infulence you
understanding.  Let us suppose for the sake of argument that the
answer is no.  Let us suppose that the malloc()ed memory used to hold
the contents of a string is only ever referenced by a single SV
structure, and when the contents of that SV changes the memory holding
the string is immediately free()d.  This may or may not be grossly
untrue but this cannot matter as none of this is relevant.

>  Really?  Doesn't the one handle the other?

No.

> And why is the reference count of $e1 not zero to begin with?

The first reference to the structure holding the value of $e1 is the
'pad' that associates that structure the the name '$e1'.   

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\

Subject: 
--text follows this line--


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

Date: Fri, 06 Apr 2001 23:30:32 GMT
From: "Roman Filippov" <NO_SPAM_klubbheads@home.com>
Subject: Regexp & function?
Message-Id: <sksz6.165236$A6.37678113@news4.rdc1.on.home.com>

How can I substitute a match with a function?
For example:

$text =~ s/<\include %([^%>]+)\%>/any_function(\1)/g;

sub any_function {
 ... works with text ...
return;
}

Thanx.




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

Date: Fri, 06 Apr 2001 23:57:13 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Regexp & function?
Message-Id: <tcslupnb9ulua9@corp.supernews.com>

Roman Filippov (NO_SPAM_klubbheads@home.com) wrote:
: How can I substitute a match with a function?
: For example:
: 
: $text =~ s/<\include %([^%>]+)\%>/any_function(\1)/g;

Your use of backslashes is rather weird.  Those on the match side don't
mean anything, while on the replacement side you want $1 rather than \1.

As for how to invoke your function, just use the /e modifier.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "When the going gets weird, the weird turn pro."
   |               - Hunter S. Thompson


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

Date: Sat, 7 Apr 2001 03:17:35 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Reverse DNS Lookup
Message-Id: <slrn9ct1mq.m7.efflandt@efflandt.xnet.com>

On 6 Apr 2001 20:03:31 GMT, Anthony Delorenzo <ajdelore@sfu.ca> wrote:
>I'm currently using a small bit of code to do reverse DNS lookup:
>
>my $ip = $ENV{'REMOTE_ADDR'};
>my $ip_addr = pack ('C4', (split /\./, $ip) );
>my $hostname = gethostbyaddr ($ip_addr,2);
> 
>I have two questions about this:
>
>1) I have been unable to find any documentation that can satisfactorily
>tell me what the ADDRTYPE argument (the second one supplied to the
>gethostbyaddr function) is.  I've looked through various man pages and
>what not.  If anyone can point me to something that will explain this, it
>would be great.  

Not sure, but it may have something to do with whether the IP is ipv4
(current method) or ipv6 (32-bit), but just guessing.  In the socket
module it is known as AF_INET.

>I realize it probably has more to do with DNS than perl...  The standard
>perl documentation doesn't even give an example of the functions use,
>however.  I found some old code from a 1996 article that led me to use the
>value of '2', but I really don't know why or for what.
>
>2) How reliable is gethostbyaddr?  It seems to run fine under Unix, but
>I've also seen (more complex) scripts that use Net::DNS to perform the
>lookups.  Is there any reason to prefer one method over the other?

gethostbyaddr uses your local resolver, which may find an answer in
/etc/hosts (\windows\hosts) if your system is configured to look there
first.  That may be a different answer than you get from Net::DNS (or
nslookup).  As an example, since my hostname (PPP) is not always online, I
use a loopback IP for it locally (don't have Net::DNS on this box):

#!/usr/bin/perl -w
use Socket;
my $host = "efflandt.xnet.com";
my ($ip,$rhost,$daddr,$dhost);
$ip = join(".",unpack("C4",scalar gethostbyname($host)));
print "Local IP for $host is $ip\n";
$rhost = gethostbyaddr(inet_aton($ip), AF_INET);
print "Local name for $ip is $rhost\n";
($server,$daddr) = grep(/Addr/,`nslookup $host`);
print "DNS $daddr";
$daddr =~ /([\d.]+)/;
($dhost) = grep(/Name/,`nslookup $1`);
print "DNS $dhost";

RETURNS:
Local IP for efflandt.xnet.com is 127.0.0.2
Local name for 127.0.0.2 is efflandt.xnet.com
DNS Address:  199.245.227.117
DNS Name:    efflandt.xnet.com

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Fri, 06 Apr 2001 22:21:54 GMT
From: "Waarddebon" <Waarddebon@chello.nl>
Subject: time difference 2 
Message-Id: <6krz6.37943$Xx6.515584@Flipper>

On my site I want to display the difference in time between a file on my
host and the current time on my host.
I've got these lines, notice the last line, it should display the remaining
time in hours.
but somehow it doesn't work right... it gives me as result: 274046.027222222
(hours ????)
While the file it should check (zandloper.txt) is created less then 10 hours
ago.
What am I doing wrong here...

$file="/data1/hm/babe/cgi-bin/zandloper.txt";
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,
$blks)= stat($file);
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst)=
localtime($mtime);
$year= 1900 + $year;
$tijd=($mtime/3600);






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

Date: Fri, 6 Apr 2001 20:19:31 -0500
From: "Jake Keith" <jlkeith@bellsouth.net>
Subject: Using perl in an NT logon script
Message-Id: <RYtz6.4063$be.65267@news1.atl>

I have what is very possibly a 'newbie' question. I want install perl on my
comps. NT server that acts as the main file & print server for an office of
100 pc's running win98.  My question:  if I install perl on the network and
give it's folder the appropriate permissions, can I use it in the users
logon.bat script i.e. run perl scripts on their machine when they logon.
example, tell me if this would work:


net use p: \\NTFOO\PERL
net use l: \\NTFOO\SCRIPTLIB
p:\bin\perl l:\audit.pl
net use /del p:
net use /del l:

please respond using email. Thank you!

jake keith

jlkeith@bellsouth.net





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

Date: Fri, 06 Apr 2001 22:43:05 -0600
From: Dmitry Epstein <mitiaNOSPAM@northwestern.edu.invalid>
Subject: Re: what are the new languages?
Message-Id: <3ACE9AD9.5F515330@northwestern.edu.invalid>

I tried installing the IDE, but right away the installer warned me that
the program won't work with directories that have spaces in them.  What
the hell?!  I've never seen this before.  If it can't even work
correctly in Windoze environment, why would I need such crap?  Better
just use the text editor that I am using now (EditTab).

"wayne.keenan" wrote:
> 
> Dmitry Epstein wrote:
> 
> >
> > Have you used PerlMagic?  How does it compare to ActivePerl (which I am
> > currently using)?
> >
> 
> not yet, I have downloded the GNU toolset in order to compile the Perl system.
> It's a bit more bother to setup, but hopefully the ability to use (most/ 90% ?)
> of the modules directly
> from CPAN will be a big plus.  Especially for the newly release 100% perl ones
> (mostly!).
> 
> I don t know about u but the Active state repository is a bit behind for my
> likings.  This way
> I can get Gtk up and running so I can use CSC Mail,  unitl I get my linux box
> back up anyway.
> 
> Wayne

-- 
Dmitry Epstein
Northwestern University, Evanston, IL.  USA
mitia(at)northwestern(dot)edu


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

Date: 07 Apr 2001 02:46:39 GMT
From: grapeape@aol.comjunk (GrapeApe)
Subject: Why Perl?
Message-Id: <20010406224639.03914.00002106@ng-fh1.aol.com>

Please excuse the broad simplicity of this question, but it is almost 'pre-faq'
in its nature (I am rereading the FAQs by the way).

I am not really a programmer of any sort by nature. But I did get interested in
how I could edit text using GREP. I would ask all sorts of 'how do I do this
with a regex' questions on usenet, and the answer would inevitably be, "Gee,
you really ought to to this in Perl". 

I stopped doing grep search and replace and sort functions with my text editor
(BBEdit) for a while, when I lost the library of Grep patterns I had created
during disk maintenance.  But I could get to a certain point merely using Grep.
Then I would have to turn to Applescripting for some procedures (cleaning
quoted printable), and a few plug ins that extended sorting features.

I found O'Reilly book on Regular Expressions to be pretty helpful, and I
finally dove in and got the Llama and Camel books (Actually I got the CD of all
O'Reilleys Perl books)

Then I got involved in other things and forgot about it. Slowly rebuilding some
of my Grep patterns, sort of starting the learning process over from scratch,
not sure if I will get a huge boost of enthusiasm again to lead me beyond the
immediate problem solving that led me down this path.

Thats why I ask, why Perl? What can it do for me? It certainly was embedded in
the answer to many of my specific questions in the past, but I don't know if I
can't find the baby steps back into exploring the language again. Perhaps you
will see pathways I do not.

Comments? TIA


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

Date: Fri, 06 Apr 2001 23:05:42 -0600
From: Dmitry Epstein <mitiaNOSPAM@northwestern.edu.invalid>
Subject: Re: Why Perl?
Message-Id: <3ACEA026.648DA16B@northwestern.edu.invalid>

I don't know.  If you don't need to do any programming whatsoever (other
than using grep) you may not be needing Perl.  Myself, I came to Perl
through Unix shell scripts.  I used csh scripts to run batch jobs with
some relatively simple data manipulation in them (like take output of
one program and generate input for another).  Then I had a very
practical problem: I had to do some work on an offline PC, and I
realized that I would save myself a lot of time and inconvenince if only
I could run scripts like I did on Unix.  This is when I remembered what
I heard about Perl, and on a whim decided to learn it (I knew that there
were ports of Perl for PC).  After that I never used Unix shell scripts
again, and I started doing a lot more with Perl.

GrapeApe wrote:
> 
> Please excuse the broad simplicity of this question, but it is almost 'pre-faq'
> in its nature (I am rereading the FAQs by the way).
> 
> I am not really a programmer of any sort by nature. But I did get interested in
> how I could edit text using GREP. I would ask all sorts of 'how do I do this
> with a regex' questions on usenet, and the answer would inevitably be, "Gee,
> you really ought to to this in Perl".
> 
> I stopped doing grep search and replace and sort functions with my text editor
> (BBEdit) for a while, when I lost the library of Grep patterns I had created
> during disk maintenance.  But I could get to a certain point merely using Grep.
> Then I would have to turn to Applescripting for some procedures (cleaning
> quoted printable), and a few plug ins that extended sorting features.
> 
> I found O'Reilly book on Regular Expressions to be pretty helpful, and I
> finally dove in and got the Llama and Camel books (Actually I got the CD of all
> O'Reilleys Perl books)
> 
> Then I got involved in other things and forgot about it. Slowly rebuilding some
> of my Grep patterns, sort of starting the learning process over from scratch,
> not sure if I will get a huge boost of enthusiasm again to lead me beyond the
> immediate problem solving that led me down this path.
> 
> Thats why I ask, why Perl? What can it do for me? It certainly was embedded in
> the answer to many of my specific questions in the past, but I don't know if I
> can't find the baby steps back into exploring the language again. Perhaps you
> will see pathways I do not.
> 
> Comments? TIA

-- 
Dmitry Epstein
Northwestern University, Evanston, IL.  USA
mitia(at)northwestern(dot)edu


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

Date: Sat, 07 Apr 2001 01:23:25 GMT
From: NJ Verenini <nverenin@san.rr.com>
Subject: Win32 fork() hangs - activestate perl build 623
Message-Id: <h_tz6.140805$GV2.37174133@typhoon.san.rr.com>

I need some enlightened advice. This short test program (included at the 
end) hangs in Win32 if $maxproc > 2. It works on Linux/perl 5.6.0 with any 
number.

I ran into this when trying to port some unix perl scripts to windows that 
make liberal use of fork and pipes. The general strategy in these scripts 
is to read from the pipe in the child till the parent tells it to exit. 
There needs to be at least 10 of these subprocesses available, hence the 
roadblock on Win32.

I've read some stuff about the careful use of waitpid() to make sure of 
proper cleanup, but I am unsure of how it would be correctly applied to 
this example. (Note waitpid is called after all the processes are started 
and then told to exit through the pipe.)

When running this with perl -d it wedges in the third call to fork(); it 
never returns and must be killed. The cpu is idle during this time. 
(Hopefully the debugger is not being misleading about where.)

Change $maxproc = 3 to see the hang. 

Example code (forktest.pl): 

# fork tester. 
use IO::Handle; 

use strict; 

my $maxproc = 2; 
my @allpids; 

select STDERR; 

print "Starting " . ($maxproc) . " processes.\n"; 

for (0..$maxproc-1) 
  { 
    my ($r, $w); 
    my $pidinfo = {}; 

    pipe ($r, $w); 
    $r->autoflush (1); 
    $w->autoflush (1); 

    my $pipe = { READER => $r, 
                 WRITER => $w }; 

    $pidinfo->{PID} = 0; 
    $pidinfo->{PIPE} = $pipe; 

    my $pid = fork (); 

    if ($pid) 
      { 
        $pidinfo->{PID} = $pid; 
        close ($pipe->{READER}); 
        push (@allpids, $pidinfo); 
        print "Made process $pid, r=$r, w=$w\n"; 
      } 
    else 
      { 
        die "cannot fork" unless defined $pid; 
        close ($pipe->{WRITER}); 
        my $h = $pipe->{READER}; 
        chomp (my $line = <$h>); 
        print "Child $$: From parent: $line\n"; 
        
        print "Child $$ exiting\n"; 
        close ($pipe->{READER}); 
        exit (0); 
      } 
  } 

print "\nTelling all " . scalar (@allpids) . " to exit\n"; 
foreach (@allpids) 
  { 
    my $pid = $_->{PID}; 
    my $h = $_->{PIPE}->{WRITER}; 
    print "Writing to $pid, handle $h\n"; 
    print $h "Now you will die, process $pid.\n"; 
    waitpid ($pid, 0); 
  } 
print "\nDone.\n"; 

__END__ 


-- 
nverenin@san.rr.com


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 646
**************************************


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