[22732] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4953 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 7 14:11:32 2003

Date: Wed, 7 May 2003 11:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 7 May 2003     Volume: 10 Number: 4953

Today's topics:
    Re: @Array - making it null <barryk2@SPAM-KILLER.mts.net>
    Re: @Array - making it null <uri@stemsystems.com>
    Re: @Array - making it null <uri@stemsystems.com>
    Re: @Array - making it null <uri@stemsystems.com>
        Can I pretend that I am from other address in CGI ? <perseus_medusa@hotmail.com>
    Re: Can I pretend that I am from other address in CGI ? <nobull@mail.com>
    Re: Extracting part of the contents of one var into ano <nospamkz15mapson@tellabs.com>
    Re: Forcing an rvalue context on a scalar expression <uri@stemsystems.com>
    Re: Forcing an rvalue context on a scalar expression <nobull@mail.com>
    Re: Forcing an rvalue context on a scalar expression <skuo@mtwhitney.nsc.com>
    Re: How do you create a biniary file in Perl. <mjcarman@mchsi.com>
    Re: How do you create a biniary file in Perl. <flavell@mail.cern.ch>
    Re: How do you create a biniary file in Perl. <flavell@mail.cern.ch>
    Re: How do you create a biniary file in Perl. (Randal L. Schwartz)
    Re: How do you create a biniary file in Perl. <flavell@mail.cern.ch>
    Re: How do you create a biniary file in Perl. <mjcarman@mchsi.com>
    Re: How does perl make differences? <jurgenex@hotmail.com>
    Re: How does perl make differences? (i5513)
        how many arguments ...... (a_wim)
    Re: How to fork and PID - revisited ctcgag@hotmail.com
        Newbie - packing Perl application for distribution <ctrueman@wavesoftware.com>
    Re: Open With? <cwilbur@mithril.chromatico.net>
        print <<"ending_print_tag"; <me@webmasterdave.co.uk>
    Re: print <<"ending_print_tag"; <nobull@mail.com>
    Re: print <<"ending_print_tag"; <me@webmasterdave.co.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 7 May 2003 08:28:36 -0500
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: @Array - making it null
Message-Id: <MPG.1922c5fb4a383ec09897c1@news.mts.net>

[This followup was posted to comp.lang.perl.misc]

In article <MlZta.759942$L1.215064@sccrnsc02>, Brad Walton 
(sammie@greatergreen.com) says...
> This is really basic, I am sure. But, I am not quite sure how to search for
> it, so maybe by explaining it I can get some help:
> 
> I have an @Array which is defined. I process the info. Now I want the @Array
> to be null, so I may do the process all over again. What is the proper
> syntax to make an @Array disappear?
> 
> Thanks,
> Brad


undef @Array;

*** OR ***

@Array = ();




-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: Wed, 07 May 2003 14:12:52 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: @Array - making it null
Message-Id: <x7r87aonff.fsf@mail.sysarch.com>

>>>>> "HB" == Helgi Briem <helgi@decode.is> writes:

  HB> my ($name,$length,$position,$quality) = split;

  HB> undef $length;
  HB> undef $quality;
  HB> print "name $position";


  HB> my ($name,undef,$position,undef) = split;
  HB> print "name $position";

  HB> Later maintainer is unclear on what is contained
  HB> in the undefined fields of the input file, although
  HB> I could put it in comments, I suppose.

my ( $name, $position ) = (split)[0, 2];

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Wed, 07 May 2003 14:18:57 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: @Array - making it null
Message-Id: <x7of2eon5a.fsf@mail.sysarch.com>

>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

  AS> If I may presume to answer for Uri here, I don't think there is any
  AS> objection to using undef() with scalars.

nah, don't speak for me :). i have been looking at all uses of undef and
i find so few valid ones. in over 6k lines of one project, i have used
it 3 times. and i don't do anything special to code around undef. i just
don't think and design code where it is needed. there are so many ways
to not use it that are clear and concise.

i know of a few cases where using undef to generate an undefined value
is needed. one is where you are returning a value in a sub called in a
list context. a plain return returns () which is different than return
undef. you may actually want to have a real undef value in that
list/array that gets the sub's values. 

and if you want to be annoying (which i don't there) you can create
undef values like:

	return do{ my $foo } ;


but most cases of $foo = undef can be removed by decent design and use
of scope. so that only leaves the above case and maybe a couple of
others where it is needed. i tend to see use of undef as a red flag now.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Wed, 07 May 2003 14:19:38 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: @Array - making it null
Message-Id: <x7llxion46.fsf@mail.sysarch.com>

>>>>> "BK" == Barry Kimelman <barryk2@SPAM-KILLER.mts.net> writes:

  BK> undef @Array;

BAD. please read other responses before jumping in.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Wed, 7 May 2003 22:36:22 +0800
From: "j" <perseus_medusa@hotmail.com>
Subject: Can I pretend that I am from other address in CGI ?
Message-Id: <3eb9194d@newsgate.hknet.com>

Hi all ,

    I am using cgi to act like a proxy. When a browser access link like
http://local_server/foo.cgi?file=foo.html
Then, foo.cgi will get
http://remote_server/foo.html
and then process it and send it to the browser. However, the images, say
foo.gif is in
http://remote_server/foo.gif
So when I send it directly to the client, the browser will think that the
html file is from local_server and will try to get the image at
http://local_server/foo.gif

So how can I resolve this ?

Thanks.

Perseus




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

Date: 07 May 2003 18:03:54 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Can I pretend that I am from other address in CGI ?
Message-Id: <u9ptmu1yf9.fsf@wcl-l.bham.ac.uk>

"j" <perseus_medusa@hotmail.com> writes:

>     I am using cgi to act like a proxy. When a browser access link like
> http://local_server/foo.cgi?file=foo.html
> Then, foo.cgi will get
> http://remote_server/foo.html
> and then process it and send it to the browser. However, the images, say
> foo.gif is in
> http://remote_server/foo.gif
> So when I send it directly to the client, the browser will think that the
> html file is from local_server and will try to get the image at
> http://local_server/foo.gif
> 
> So how can I resolve this ?

HTTP has the Content-location header.  I do not know if all popular
browsers respect it.

ISTR soemting that could go in the HTML <HEAD> too.  I mean something
other than the obvious <META HTTP-EQUIV="Content-location">!

Of course, if you are parsing foo.html, why not just change all the
URLs?

Or maybe make your proxy script take 'foo.html' as PATH_INFO so that
all relative links get proxied too? 

None of this, of course, has anything at all to do with Perl.

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


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

Date: Wed, 07 May 2003 15:46:41 +0100
From: kz15 <nospamkz15mapson@tellabs.com>
Subject: Re: Extracting part of the contents of one var into another
Message-Id: <3EB91C51.4060404@tellabs.com>

Abigail wrote:
> Bigus () wrote on MMMDXXXV September MCMXCIII in

OT               on 3535 September 1993

back to the future...

[cut]

> 
>     ($name) = $sentence =~ /(\S+)$/;
> 
> Or:
> 
>     ($name = $sentence) =~ s/.* //;
> 
> Or:
> 
>     $name = substr $sentence => 1 + rindex $sentence => " ";
> 

JAPHish but cute, this last one.

JAPWCBSIPAGW
(Just Another Problem Which Can Be Solved In Perl A Gazillion Ways)

Horribile dictu:

(undef,$name) = split "is ",$sentence;

> Abigail

Regards,

Zoltan Kandi, M. Sc.



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

Date: Wed, 07 May 2003 14:11:15 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Forcing an rvalue context on a scalar expression
Message-Id: <x7u1c6oni4.fsf@mail.sysarch.com>

>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

  AS> There is clearly a bug involved and it is independent from the "$q{ -1}"
  AS> behavior.

  AS>     my $x;
  AS>     scalar( $x) = 123;

  AS> Can't modify scalar in scalar assignment at ...

  AS>     $_ = 123 for scalar( $x);
  AS>     print "$x\n";

  AS> 123

lvalue and aliasing are not the same thing internally. it could be
classified as a bug. report it to p5p and let them fight over it.

  AS> I may be naive, but I'd try to supplant an alias to a read-only
  AS> location with undefined content for the un-creatable alias.  That
  AS> way an error would only occur if you try to assign to the location,
  AS> the read behavior would be as it should be.

i disagree. it think it should stay a runtime error. maybe the scalar/do
stuff that works should also fail. again, let p5p hash it out. these are
not things i will ever run into in my code so i don't have much concern
about them. they are all poor user code and odd corner cases.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 07 May 2003 17:36:47 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Forcing an rvalue context on a scalar expression
Message-Id: <u9y91i1zog.fsf@wcl-l.bham.ac.uk>

Abigail <abigail@abigail.nl> writes:

> Steven Kuo (skuo@mtwhitney.nsc.com) wrote on MMMDXXXV September MCMXCIII
> in <URL:news:Pine.GSO.4.21.0305061204110.24147-100000@mtwhitney.nsc.com>:
> <>  
> <>  Do you consider this less ugly?
> <>  
> <>  foo(${\(defined $q[-1]? $q[-1]: undef)});
> 
> 
> Why not:
> 
>     foo (@q ? $q [-1] : undef)

That's a very simple and elegant solution in the specific case of the
example of $q[-1] causing "Modification of non-creatable array value
attempted".  You are focusing too closely on the simplified example
used to illustrate the question and not the actual question.  In the
original situation I happend to encounter this was really more like
func()->[-1] where func() is quite expensive.

The question (see subject line) was "forcing an rvalue context".  The
expression $q[-1] was just an example of the type of expression on
which one may want to do this.

Once again I think you are falling into the trap of trying to globally
optomise illustative examples.  Programming examples often optomise
away completely because they do not do anything.

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


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

Date: Wed, 7 May 2003 10:54:25 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: Forcing an rvalue context on a scalar expression
Message-Id: <Pine.GSO.4.21.0305071046290.29843-100000@mtwhitney.nsc.com>

On 7 May 2003, Brian McCauley wrote:

> Abigail <abigail@abigail.nl> writes:
> 
> > Steven Kuo (skuo@mtwhitney.nsc.com) wrote 
> > <>  ... 
> > <>
> > <>  foo(${\(defined $q[-1]? $q[-1]: undef)});
> > 
> > 
> > Why not:
> > 
> >     foo (@q ? $q [-1] : undef)
> 
> That's a very simple and elegant solution in the specific case of the
> example of $q[-1] causing "Modification of non-creatable array value
> attempted".  You are focusing too closely on the simplified example
> used to illustrate the question and not the actual question.  In the
> original situation I happend to encounter this was really more like
> func()->[-1] where func() is quite expensive.
> 
> The question (see subject line) was "forcing an rvalue context".  The
> expression $q[-1] was just an example of the type of expression on
> which one may want to do this.
> 
> Once again I think you are falling into the trap of trying to globally
> optomise illustative examples.  Programming examples often optomise
> away completely because they do not do anything.
> 





But it seems that even if func()->[-1] were expensive, you could do
this:


#! /usr/local/bin/perl
use strict;
use warnings;
use Data::Dumper;

bar(@{[func()->[-1]]});
bar(@{[func(1)->[-1]]});

# -- Modification error:
# bar(func()->[-1]);

# -- Seems okay:
# bar(do {func()->[-1]});


sub func {
    my @array = $_[0]? (3, 2, '') : ();
    return \@array;
}

sub bar {
    print Dumper $_[0];
}


Or is there some performance penalty that I've not recognized?


-- 
Regards,
Steven



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

Date: Wed, 07 May 2003 08:04:19 -0500
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: How do you create a biniary file in Perl.
Message-Id: <b9b08k$s3d2@onews.collins.rockwell.com>

On 5/7/2003 3:01 AM, Tassilo v. Parseval wrote:
> Also sprach Mihai N.:
>>
>>> binmode F;
>>> print F "\n";
>>> 
>>> # or without binmode
>>> print F "\012";
>> 
>> I just tested it on Windows and if you don't use binmode the result
>> for both "\n" and "\012" is 0D 0A.
> 
> Hmmh, nasty. So I was wrong and Xavier's and Josef's posting suggest 
> that things are perhaps not quite as consistent as they should be. I
> also think that your observations violate what perlport.pod has to 
> say.

Yes, perlport seems to have a number of errors in the Newlines section.
The stuff about chop() only removing half the newline on DOS, for example.

I keep meaning to submit a patch for this.

> For example here:
> A common misconception in socket programming is that "\n" eq "\012" 
> everywhere. When using protocols such as common Internet protocols, 
> "\012" and "\015" are called for specifically, and the values of the 
> logical "\n" and "\r" (carriage return) are not reliable.
> 
> print SOCKET "Hi there, client!\r\n";      # WRONG
> print SOCKET "Hi there, client!\015\012";  # RIGHT
> 
> So both would result in "0D 0D 0A", no?

Under DOS/Win, yes.

Hmm. I would expect \r to be reliable, yet perlport claims that it's a
LF on Mac. Is there anyone with a Mac able to confirm or refute this?

I think a large part of the problem with perlport is that no one person
really has experience with all the platforms they're trying to comment
on. I'd like to patch this, but I don't feel that I have all the
resources, either. Also, it seems to me that a proper rewrite of this
section should make use of IO layers, and I've not played with them much
yet.

-mjc



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

Date: Wed, 7 May 2003 15:48:08 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: How do you create a biniary file in Perl.
Message-Id: <Pine.LNX.4.53.0305071536070.22309@lxplus013.cern.ch>

On Wed, May 7, Michael Carman inscribed on the eternal scroll:

> Hmm. I would expect \r to be reliable,

It _is_ reliable: it always matches \r  (when handling native
file formats).

> yet perlport claims that it's a LF on Mac.

That's so as not to confuse it with the CR  ;-)

> Is there anyone with a Mac able to confirm or refute this?

I'm quite sure that perlport tells the truth.

Your problem is that you're trying to compare things that shouldn't be
compared.  \n matches \n, and \r matches \r, when handling native text
file formats.  \012 matches \012 when reading files as binary, but
might or might not match \n depending on platform. And so on. That's
the message of perlport.  (And don't forget EBCDIC-based platforms)
(and sockets).

> I think a large part of the problem with perlport is that no one person
> really has experience with all the platforms they're trying to comment
> on.

Well, I assumed that whoever wrote the bit about VAX/VMS had something
specific in mind, but my recollection of VAX/VMS was that it supported
a whole range of different newline formats.  I'm not sure that's what
you're getting at here, though.

IMHO a large part of the problems which people have with perlport is
that their reading is clouded with their preconceptions of how they
suppose it ought to be (but isn't).  If they could come to it with a
clear uncluttered head, it would make more sense to them, AFAICS.
But no amount of rewriting perlport could force the reader to clear
their head.


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

Date: Wed, 7 May 2003 16:10:26 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: How do you create a biniary file in Perl.
Message-Id: <Pine.LNX.4.53.0305071549340.22309@lxplus013.cern.ch>

On Wed, May 7, Tassilo v. Parseval inscribed on the eternal scroll:

> I also think that your observations violate what perlport.pod has to
> say. For example here:
>
>     A common misconception in socket programming is that "\n" eq "\012"
>     everywhere. When using protocols such as common Internet protocols,
>     "\012" and "\015" are called for specifically, and the values of the
>     logical "\n" and "\r" (carriage return) are not reliable.
>
>         print SOCKET "Hi there, client!\r\n";      # WRONG
>         print SOCKET "Hi there, client!\015\012";  # RIGHT
>
> So both would result in "0D 0D 0A", no?

No: when you're working with sockets then you're expected to be
reading and writing them as binary, so that the DOS newline semantics
don't come into play.

Generally speaking, if you're handling native text file formats then
it's correct to work with \n and \r notation and read and write in
text mode.  Whereas if you're working with sockets (or forced to
handle cross-platform text formats) then it's approprate to work with
\012 and \015 (or equivalent notations) and work in binary mode.

(I'm glossing-over the character encoding layers in that presentation,
of course).

Mixing the two kinds of notation normally indicates confusion
(except in situations like e.g CGI.pm, where he tests the \t
character against a numerical value in order to detect that he's
on an ebcdic platform).


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

Date: Wed, 07 May 2003 15:13:14 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: How do you create a biniary file in Perl.
Message-Id: <5acea0cae600ffe884284f217cf815d4@TeraNews>

>>>>> "Alan" == Alan J Flavell <flavell@mail.cern.ch> writes:

Alan> Generally speaking, if you're handling native text file formats then
Alan> it's correct to work with \n and \r notation and read and write in
Alan> text mode.  Whereas if you're working with sockets (or forced to
Alan> handle cross-platform text formats) then it's approprate to work with
Alan> \012 and \015 (or equivalent notations) and work in binary mode.

And if you're using Socket (and thus IO::Socket::INET), you can import
the scalars $CR $LF and $CRLF or the constants (subroutines prototyped
with no args) of CR LF and CRLF.

Then, you never have to remember \015 and \012. :)

    use Socket qw(CR LF CRLF);
    ...
    print $socket "GET / HTTP/1.0", CRLF, CRLF;

print "Just another Perl hacker,";
-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Wed, 7 May 2003 18:19:43 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: How do you create a biniary file in Perl.
Message-Id: <Pine.LNX.4.53.0305071810110.22309@lxplus013.cern.ch>

On Wed, May 7, Randal L. Schwartz inscribed on the eternal scroll:

> Alan> \012 and \015 (or equivalent notations) and work in binary mode.
>
> And if you're using Socket (and thus IO::Socket::INET), you can import
> the scalars $CR $LF and $CRLF or the constants (subroutines prototyped
> with no args) of CR LF and CRLF.

Yessir, that's what I meant by "equivalent notations".  As "use
Socket" was mentioned right there in Perlport, I didn't go into detail
;-)

> Then, you never have to remember \015 and \012. :)

Except that on EBCDIC platforms it isn't \012, so you make a good
point as far as portability is concerned.  Fortunately, sockets
usually want to talk ASCII-based codings to each other, so then it's
more a matter of convenience than of principle...

all the best.


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

Date: Wed, 07 May 2003 11:36:24 -0500
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: How do you create a biniary file in Perl.
Message-Id: <b9bcm8$s2t2@onews.collins.rockwell.com>

On 5/7/2003 9:10 AM, Alan J. Flavell wrote:

> On Wed, May 7, Tassilo v. Parseval inscribed on the eternal scroll:
> 
>>  A common misconception in socket programming is that "\n" eq "\012"
>>  everywhere. When using protocols such as common Internet protocols,
>>  "\012" and "\015" are called for specifically, and the values of the
>>  logical "\n" and "\r" (carriage return) are not reliable.
>>
>>      print SOCKET "Hi there, client!\r\n";      # WRONG
>>      print SOCKET "Hi there, client!\015\012";  # RIGHT
>>
>> So both would result in "0D 0D 0A", no?
> 
> No: when you're working with sockets then you're expected to be
> reading and writing them as binary, so that the DOS newline semantics
> don't come into play.

The example makes two bad assumptions:
  1) That there's been a binmode(SOCKET).
  2) That the person reading it will realize that.

If you've never done socket programming, the need to use binmode() isn't
obvious (after all, you're (often) writing text, aren't you?). Also,
since text IO is the default, the absence of an explicit binmode()
implies that you *are* using the normal text semantics.

All of which conspires to confuse and distract from the point that's
being attempted here.

-mjc



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

Date: Wed, 07 May 2003 14:24:29 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How does perl make differences?
Message-Id: <xG8ua.5166$Zb5.4715@nwrddc02.gnilink.net>

i5513 wrote:
> how does perl distingue $/ var from /expression$/ ?

Trivial.
If the dollar sign is the _last_ character in the RE then obvioulsy it is
the expression for "end of string/line" because there is no variable name
following the dollar sign.
If the dollar sign is _not_ the last character in the RE then obvioulsy it
is the beginning of a variable name because the expression for "end of
string/line" doesn't make sense in the middle of an RE.

> I'd like this expression:
>
> ( |$)
> Perl take $) like a var
> ($| )
> Perl take $| like a var
> (\Z| )
> is similar but not equal
> How I can say "( |finish)"?

No idea what you mean by that

jue




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

Date: 7 May 2003 10:41:51 -0700
From: i5513@hotmail.com (i5513)
Subject: Re: How does perl make differences?
Message-Id: <a657ec02.0305070941.209de274@posting.google.com>

i5513@hotmail.com (i5513) wrote in message news:<a657ec02.0305070304.6e88dc2c@posting.google.com>...
> Well, I'm intrigued ...
> 
> how does perl distingue $/ var from /expression$/ ?

Thanks for your 2 answer ...

Now I know thath /$// (and /${/}/ is a syntax error, my question is erroneus.

My second question is the same!! var $) is not usable into a / / expresion.
/$)/ is a syntax error. 

Thanks again.


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

Date: 7 May 2003 07:23:12 -0700
From: a_wim@yahoo.de (a_wim)
Subject: how many arguments ......
Message-Id: <addcf2d2.0305070623.64147a0a@posting.google.com>

hi everybody,
can anybody tell me how i can control the numbers of assign arguments?
by using the cpan-modul getopt::long.

bye 
andi


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

Date: 07 May 2003 13:55:59 GMT
From: ctcgag@hotmail.com
Subject: Re: How to fork and PID - revisited
Message-Id: <20030507095559.731$HW@newsreader.com>

"Tony" <anthony@no_spam.movielink.net.au> wrote:

> I know that "system()" is much
> easier to use as it returns as soon as the external program
> has completed but how would I be able to kill the external
> program ?  Without knowing the PID it is hard, killing
> the perl child does not "kill" the external program (I have
> tried).

Ah, so I see.  This seems to do it, as a skeleton:

my $kid=fork;
die "couldn't fork" unless defined $kid;

if ($kid) {
  sleep 10;
  print "signalled $kid, gives return of ", (kill 15, $kid), "\n";
} else {
  my $kid2="";
  $SIG{TERM}=sub{die "Murder-suicide ", (kill 15, $kid2);};
  foreach (1..100) {
    defined ($kid2=fork) or die "Couldn't fork";
    if ($kid2) {
      wait ;
    } else {
      exec "perl slow_print.pl";
    }
  };
};

Of course, you'd probably just want to call the kill commands, not print
their return values, as I did for debugging purposes.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Wed, 7 May 2003 17:18:17 +0000 (UTC)
From: Chris Trueman <ctrueman@wavesoftware.com>
Subject: Newbie - packing Perl application for distribution
Message-Id: <Xns9374BB556A764ctruemanwavesoftware@217.32.252.50>

I have a couple of Perl utilities that I'd like to distribute to 
colleagues.  I can expect them to download and install a binary 
distribution of Perl but having them install the modules that my code 
depends on is probably too much.

Is there a simple way to package my code + that required modules that will 
make it easy for them to install the utilities?

Many thanks,



Chris.


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

Date: Wed, 07 May 2003 13:28:28 GMT
From: Charlton Wilbur <cwilbur@mithril.chromatico.net>
Subject: Re: Open With?
Message-Id: <87issmq4d5.fsf@mithril.chromatico.net>

helgi@decode.is (Helgi Briem) writes:

> PHP is basically a simplified subset of Perl, with a
> CGI module and DBI module built in.  It is used 
> only for Web programming. 

While what you point out would be perfectly true in a sane universe, I
will point out that I have seen system administration scripts written
in PHP and run (as root) with the standalone PHP interpreter.

Charlton


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

Date: Wed, 07 May 2003 17:29:54 +0100
From: David Taylor <me@webmasterdave.co.uk>
Subject: print <<"ending_print_tag";
Message-Id: <3EB93482.9000602@webmasterdave.co.uk>

Heya...

I am new to perl so bare with me...
I have a problem with -
print <<"ending_print_tag";

Say I do -

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

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print <<"ending_print_tag";
<html>
<head>
<title>Hello World</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
ending_print_tag

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

I get the following error -

  "The server encountered an internal error and was unable to complete 
your request.

     Error message:
Premature end of script headers: firstCGI.pl"

Why??? Please help, it's weird.
I have done chmod a+x /var/www/html/daves/perl/file.pl
still no good. If I change it to -

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

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<html>
<head>
<title>Hello World</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>";

------------------------------------
It runs fine!

My system is running Linux Red Hat 8.0, apache 2.0.40, perl 5.8.0.

Any help would be GREATFULLY appreciated. Thanks
(sorry this is a long post!)

 ...Dave...



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

Date: 07 May 2003 17:45:32 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: print <<"ending_print_tag";
Message-Id: <u9u1c61z9v.fsf@wcl-l.bham.ac.uk>

David Taylor <me@webmasterdave.co.uk> writes:

> Heya...
> 
> I am new to perl so bare with me...
> I have a problem with -
> print <<"ending_print_tag";
> 
> Say I do -
> 
> ------------------------------------
> 
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> print <<"ending_print_tag";
> <html>
> <head>
> <title>Hello World</title>
> </head>
> <body>
> <h1>Hello World</h1>
> </body>
> </html>
> ending_print_tag
> 
> ------------------------------------
> 
> I get the following error -
> 
>   "The server encountered an internal error and was unable to complete
> your request.
> 
>      Error message:
> Premature end of script headers: firstCGI.pl"
> 
> Why??? Please help, it's weird.

Please consult you your web servers error log to see the Perl error as
opposed to the CGI protocol error.

Random shot in the dark - there's no end of line character on the last
line of the script.

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


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

Date: Wed, 07 May 2003 18:13:36 +0100
From: David Taylor <me@webmasterdave.co.uk>
Subject: Re: print <<"ending_print_tag";
Message-Id: <3EB93EC0.5090603@webmasterdave.co.uk>

Brian McCauley wrote:
> David Taylor <me@webmasterdave.co.uk> writes:
> 
> 
>>Heya...
>>
>>I am new to perl so bare with me...
>>I have a problem with -
>>print <<"ending_print_tag";
>>
>>Say I do -
>>
>>------------------------------------
>>
>>#!/usr/bin/perl
>>print "Content-type: text/html\n\n";
>>print <<"ending_print_tag";
>><html>
>><head>
>><title>Hello World</title>
>></head>
>><body>
>><h1>Hello World</h1>
>></body>
>></html>
>>ending_print_tag
>>
>>------------------------------------
>>
>>I get the following error -
>>
>>  "The server encountered an internal error and was unable to complete
>>your request.
>>
>>     Error message:
>>Premature end of script headers: firstCGI.pl"
>>
>>Why??? Please help, it's weird.
> 
> 
> Please consult you your web servers error log to see the Perl error as
> opposed to the CGI protocol error.
> 
> Random shot in the dark - there's no end of line character on the last
> line of the script.
> 

Heya...

Thanks for that, the new line cured it, but when i took it away to 
check... it worked still :-/ very weird! Thanks for your help.

 ...Dave...



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

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


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