[10492] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4084 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 27 15:05:50 1998

Date: Tue, 27 Oct 98 12:01:30 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 27 Oct 1998     Volume: 8 Number: 4084

Today's topics:
    Re: Perl Cookbook - is this the best perl book? (Dave Till)
    Re: Perl require not always finishing on NT gregghill@my-dejanews.com
    Re: Perl require not always finishing on NT gregghill@my-dejanews.com
    Re: psychology of language choice (was Re: language war <perlguy@technologist.com>
    Re: psychology of language choice (was Re: language war <uri@fastengines.com>
    Re: Repost from Data (Joergen W. Lang)
    Re: require help on require <alexb@sig.net>
    Re: RFC - Signature (Snowhare)
    Re: RFC - Signature <bill@fccj.org>
    Re: RFC - Signature <danboo@negia.net>
    Re: RFC - Signature <bill@fccj.org>
    Re: RFC - Signature (Larry Rosler)
    Re: socket connection via udp <uri@fastengines.com>
    Re: socket connection via udp (Brand Hilton)
    Re: System command (why a LIST??) (Tye McQueen)
    Re: System command (why a LIST??) (Ilya Zakharevich)
        Using Window-target in HTTP header not outputting to co mattf@quicklink.com
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 27 Oct 1998 12:55:25 -0500
From: davet@angel.uunet.ca (Dave Till)
Subject: Re: Perl Cookbook - is this the best perl book?
Message-Id: <7151ed$26e@angel.uunet.ca>

In article <sar7lxsmv35.fsf@camel.fastserv.com>,
Uri Guttman  <uri@fastengines.com> wrote:
>so go buy some perl for morons books. who cares if you don't like
>o'reilly books. the fact they they PUBLISH errata is so far and above
>any other technical publisher that it makes o'reilly the premier honest
>publisher. i bet you could pick ANY other technical book and we could
>find FAR more errors per page than the ones published by o'reilly.

Allow me to toss in my $.02, as a (satisfied) user of several O'Reilly
books, and a former SAMS author.

To a certain extent, comparing O'Reilly to other technical book
publishers is a bit like comparing apples to oranges.  O'Reilly books
are generally designed to be the definitive reference book on a
particular subject, and usually have a long shelf life (several years
at least).  As a consequence, O'Reilly can afford to give their
authors more time to write books, and can afford to provide the time
to have several authors proofread their books.  (I wish I had been
given 18 months to write *my* book, I must say!)

Most of the other publishers in the field are trying to hit a moving
target, as they are producing books for products that have a short
shelf-life.  It's not financially feasible to be given 18 months
to write a book such as, say, Sams' *Teach Yourself Mac OS 8.5 in
24 Hours* (to pick one of their new releases at random);
by then, competing publishers would have stolen all the market,
and the product would have been superseded by a later release.

There's also a question of what readers you want to reach.  O'Reilly
books are written for experienced practitioners; other publishers
are often writing for users with less experience.  It is my belief
that no one book can satisfy the needs and expectations of both
sets of users.

And one final point:  unless you're very lucky, it's impossible
to make a living writing computer books.  This means that most
computer book writers usually have a full-time job and write in
their spare time.  I am in awe of people who can do both
for a long period of time without frying their brains.
-- 
--Dave Till, programmer/writer/web page creator/occasional performer/big geek
email: davet@uunet.ca                             WWW: http://www.net/~davet/
Disclaimer: for crying out loud, don't drag my employers into this. Get real.
"Objects in calendar are closer than they appear." - Jim Duncan


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

Date: Tue, 27 Oct 1998 19:02:11 GMT
From: gregghill@my-dejanews.com
Subject: Re: Perl require not always finishing on NT
Message-Id: <7155bj$7t7$1@nnrp1.dejanews.com>

Update:
I just found an old log file that contains errors relating to standard
perl-supplied files with the use statement (Win32.pm,Exporter.pm,ctime.pl) -
which I don't mess with.

Its as if the require and use functions intermittently get an EOF too soon,
and depending on how much of the file is read in, the syntax error varies.

*** 'E:\approot\cgi-bin\_build_tabs.cgi' error message at: 1998/08/10 09:34:51
Can't find string terminator ")" anywhere before EOF at C:\Perl\lib/Win32.pm
line 6.
BEGIN failed--compilation aborted at E:/approot/cgi-bin/common_lib.pl line 6.

*** 'E:\approot\cgi-bin\_build_health_tabs.cgi' error message at: 1998/08/11
10:46:05
Exporter.pm did not return a true value at C:\Perl\lib/Win32.pm line 3.
BEGIN failed--compilation aborted at E:/approot/cgi-bin/common_lib.pl line 6.

*** 'E:\approot\cgi-bin\_sub_addr_detail.cgi' error message at: 1998/08/11
12:36:48
Missing right bracket at C:\Perl\lib/Carp.pm line 48, at end of line
syntax error at C:\Perl\lib/Carp.pm line 48, at EOF
BEGIN failed--compilation aborted at E:/approot/cgi-bin/common_lib.pl line 6.

*** 'E:\approot\cgi-bin\_sub_message_detail.cgi' error message at: 1998/08/12
13:26:50
Exporter.pm did not return a true value at C:\Perl\lib/Win32.pm line 3.
BEGIN failed--compilation aborted at E:/approot/cgi-bin/common_lib.pl line 6.

*** 'E:\approot\cgi-bin\_build_health_tabs.cgi' error message at: 1998/08/13
09:07:36
Exporter.pm did not return a true value at C:\Perl\lib/Win32.pm line 3.
BEGIN failed--compilation aborted at E:/approot/cgi-bin/common_lib.pl line 6.

*** 'E:\approot\cgi-bin\_sub_enroll_detail.cgi' error message at: 1998/08/14
10:00:19 ctime.pl did not return a true value at
E:/approot/cgi-bin/common_lib.pl line 5.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 27 Oct 1998 19:27:40 GMT
From: gregghill@my-dejanews.com
Subject: Re: Perl require not always finishing on NT
Message-Id: <7156rc$a0o$1@nnrp1.dejanews.com>

In article <36352346.8524AC36@spider.herston.uq.edu.au>,
  Jaime Metcher <metcher@spider.herston.uq.edu.au> wrote:
> Try putting:
>
> 1;
>
> at the end of your library file to force it to return a true value.
> Otherwise it's return value will be the value of the last statement,
> which could depend on the context in which in was require'd.
>
> --
> Jaime Metcher
>

Good idea, but its already there...

The context is always the same: the library is required right after a config
file is required.  I have also found that standard Perl files are having the
same trouble (see other reply in this thread)...

I also found that someone else is having a similar problem...

> Re: Amputated Perl Code

> Author:     Tom Phoenix
> Email:      rootbeer@teleport.com
> Date:       1998/10/20
> Forums:     comp.lang.perl.misc

> On Tue, 20 Oct 1998, Justin Wilde wrote:

>> Normally these scripts run fine, but it appears that occasionally they
>> are cut short, often midway through a bracketed block of code.  I
>> assume this is what's happening because the line of code the perl
>> compiler considers to be EOF is only partway through my file.
>>
>> What might cause this?  The scripts are used only to process STDIN and
>> display html pages.  Concurrency wouldn't be an issue, would it?

> Is this happening "all by itself"? It sounds as if perl is seeing the end
> of file before the true end of file. This could be caused by a problem in
> your IO system, or mmmmmmmmmmaybe an unexpected signal coming in during
> the time that Perl is parsing your program. My best guess is that your
> files are on NFS or a similar system which is not delivering the whole
> file every time. You may be able to "stress test" the system to see how it
> behaves, but be sure to ask for permission first. Good luck!

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


My code is sitting on a local drive (E:), with Perl installed on C:


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 27 Oct 1998 19:27:08 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: psychology of language choice (was Re: language war ...)
Message-Id: <36361E8C.1D92FA0C@technologist.com>

amen!

brent


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

Date: 27 Oct 1998 14:53:28 -0500
From: Uri Guttman <uri@fastengines.com>
Subject: Re: psychology of language choice (was Re: language war ...)
Message-Id: <sarogqx93yf.fsf@camel.fastserv.com>


i got this email reply which make some legitimate comments on my previous post
so here is the reply and my rebuttal.

also thanx to all who emailed me positive responses about the essay. you
could post those too!

uri


>>>>> "PFD" == Paul F Dubois <dubois1@llnl.gov> writes:

  PFD> Do you realize that you just said: a. I don't know Python b. I
  PFD> have an opinion about it (e.g., it forces a rigid coding style on
  PFD> the user)

i meant i don't know python like i know perl. i could learn it in a day
if desired. i can learn almost any modern language in a day or so to
minimally function and get a feel for it. i have seen enough python to
get a feel for its style and flavor. also i have seen enough flame wars
about it vs. perl to know i am on the perl side.

  PFD> Apparently (b) is derived from "looking at a few snippets". That
  PFD> isn't proper discourse.

  PFD> FYI: I know both Perl and Python and see no difference between
  PFD> them with respect to this issue. You wouldn't call the need to
  PFD> put { } around some things in a language a "rigid coding
  PFD> style". It is just the syntax.  Likewise, indentation in Python
  PFD> is simply its syntax.

i agree. but the syntax doesn't agree with the way i think in code. i
don't like the C syntax which allows dangling statements after if/while
without {}, so i always use {}. i like {}. it sticks out visually for
me. i don't like indenting as a syntax thing since i have my own indent
style, which may not fit.

  PFD> Please note this reply is not posted to the group. I try to not
  PFD> post criticisms of other people.

this could have been posted as your comments were reasonable and i had a
reasonable response.

again, i don't say python is a bad language. it just isn't to my taste
and way of thinking. i came from the unix/shell/awk/c/lisp world and
perl just subsumes all of them with similar syntax and semantics. python
doesn't map to my mind the same. i don't have to be an expert in cobol
to know i would hate it too. and i have seen as much cobol as i have
seen python. i am a computer professional and picking up languages is
second nature to me. my quick glance at python is enough for me.

uri


-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Tue, 27 Oct 1998 20:16:46 +0100
From: jwl@_munged_worldmusic.de (Joergen W. Lang)
Subject: Re: Repost from Data
Message-Id: <1dhkjyr.izsl30ik9g5cN@host050-210.seicom.net>

<toiday@my-dejanews.com> wrote:

> In article <slrn72vns2.oi4.sholden@pgrad.cs.usyd.edu.au>,
>   sholden@cs.usyd.edu.au wrote:
> > On Thu, 22 Oct 1998 18:09:22 GMT, toiday@my-dejanews.com
> >     <toiday@my-dejanews.com> wrote:
> > >I'm writing a cgi program.  Because program generate a webpage that need to
> > >update the information, I include the following:
> > >
> > ><META HTTP-EQUIV="REFRESH" CONTENT="120">
> > >
> > >to refresh every 2 minutes.  This webpage would also do "POST".  The
> > >problem is if someone use Microsoft IE (version 4) to submit the data,
> > >after two minutes, when it suppose to REFRESH, it would ask "Repost
> > >from Data?". However, it work fine for Netscape.  Can someone tell me
> > >what is going on with IE?  How can I fix that problem?
> >
> > I think you just use...
> > <META HTTP-EQUIV="REFRESH" CONTENT="120" MISC="POST DAMN YOU!!!!!!">
> >
> > Then again I write perl not HTML... maybe you should try a more
> > appropriate news group...
> >
> 
> Do you parents or college teach you to be an asshole?  If you don't know the
> answer then shutup.  May be one day when you grow up, get out of college and
> get a real job, you may understand.  Meanwhile, computer is not a toy.
> Newsgroup is not the place for you to harass people.  Don't waste you
> parent's hard working money.

Sounds like you're talking to yourself. My compliments for such a great
ability for self-reflection and -correction. 
 
The answer <sholden@cs.usyd.edu.au> was giving is IMO more than
appropriate. The only thing, Perl has to do with your question is that
it _might_ be the language, which creates your meta-tag (which you did
not say). 

Asking about the behaviour of a meta-tag or a special browser has
_nothing_ to do with Perl. Thus pointing you in the direction where you
might find the answer you are looking for can't be that wrong.

Your way of reacting in such an inappropriate way, insulting people,
etc. won't really help you get answers you are looking for. Learn some
nettiquette, learn to ask questions in a way, that encourages people to
answer you. Saying "If you don't know the answer then shutup" will
easily make you "King of the Killfiles" but it won't get you the answers
you are looking for. 

Better rethink your strategy.

bye,

Joergen
-- 
  To reply by email please remove _munged_ from address Thanks !
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"


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

Date: Tue, 27 Oct 1998 13:35:01 -0600
From: Alexander Bibighaus <alexb@sig.net>
Subject: Re: require help on require
Message-Id: <36362065.26206F80@sig.net>


The require key word simply loads a file into your program
similar to #include in C.  However, Perl does not load
a file that is already loaded.

One big difference in "use" and "require" is that "use" is executed
at compile time.  This guarantees that all modules have been
successfully
loaded.  

You can read more in "Advanced Perl Programming - Chap 6"

-alexander

Maelstrom wrote:
> 
> Hi.  I'm currently trying to sort through all my hacked-together scripts and
> create some libraries of structured, reusable code which I use with
> something like
> require "common.pl";
> 
> At the moment everything's in common.pl but I'd like to split things up
> further into email/cgi/password etc etc.  Anyway a lot of the routines in
> the sub-libraries still use routines from common.pl so my question is if I
> have a script with a header like this
> 
> #!/usr/bin/perl
> require "common.pl";
> require "htpasswd.pl";
> require "email.pl";
> 
> where htpasswd.pl and email.pl both have ''require "common.pl";`` have I
> just loaded three instances of common.pl into memory or will the compiler
> ignore duplicate files?  Also is there any benefit in using the use
> statement and modules rather than require?
> 
> Thanks,
> --Steve
> "In fact, it's cold as Hell.  The bottom,      __________________________
> frozen part, not the rivers of fire part."    /       ~This space for let~
> Joe Bay                                      /http://www.sexgods.base.org/


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

Date: 27 Oct 1998 11:06:30 -0700
From: snowhare@xmission.xmission.com (Snowhare)
Subject: Re: RFC - Signature
Message-Id: <715236$803$1@xmission.xmission.com>



Nothing above this line is part of the signed message.

In article <3635E211.25F64CD8@fccj.org>,
Bill Jones, FCCJ Webmaster <webmaster@fccj.org> wrote:
>Hi :]
>
>Anybody have ideas about shortening this a bit?
>(My first 'official' attempt :)
>
>Thx!
>-Sneex- 
>______________________________________________________________________
>Bill Jones  |  904/632-3089  |  http://www.fccj.org/cgi/mail?webmaster
>----------------------------------------------------------------------
>$perlRulez = "FCCJ Webmaster";
>if ($perlRulez =~ /(F)(C)(C)(J)( )(W)(e)(b)(m)(a)(s)(t)(e)(r)/) {
>    print "$4", chr(ord($12)+1), "$11$12$5", uc($10), chr(ord($9)+1),
>        chr(ord($14)-3), "$12", lc(chr(ord($1)+2)), reverse($14,$13),
>        "$5", uc(chr(ord($14)-2)), "$13$14", chr(ord($9)-1), "$5",
>        uc(chr(ord($7)+3)), "$10", chr(ord($10)+2),chr(ord($9)-2),
>        reverse($14,$13), "\n"; }


Nope. Sorry. Not a one.

- --
my $name=join('',reverse(split(//,'Benjamin "Snowhare" Franz')));
$_='024e046b794c446f25423a6375477d6c14450a39447a07637e';
s/(..)/push(@ARGV,hex($1))/eg;while($_=chop $name){ 
$_=ord^shift;$_+=$a;$_%=108;print chr(($a=$_)+10)}


Version: 2.6.2

iQCVAwUBNjYKoujpikN3V52xAQF5hgQAvEDrwDEEh7MNKCFZDD/13cgoY2cQerE0
dol/T7pyWBU0TmwKv87KY704HndM2TlRqqHghzmd1m4snhhKP7N0EEyu5B+WPrtn
59e1cZ+t94e4mcjfVxjt6EdhVQzQYSsi9Grmh48ua6zm52kyVUxWcXWpPQ73FxU3
nHnVqdEkoIM=
=lc58
-----END PGP SIGNATURE-----


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

Date: Tue, 27 Oct 1998 12:38:42 -0800
From: Bill Jones <bill@fccj.org>
Subject: Re: RFC - Signature
Message-Id: <36362F52.85576F36@fccj.org>

Snowhare wrote:
> >$perlRulez = "FCCJ Webmaster";
> >if ($perlRulez =~ /(F)(C)(C)(J)( )(W)(e)(b)(m)(a)(s)(t)(e)(r)/) {
> >    print "$4", chr(ord($12)+1), "$11$12$5", uc($10), chr(ord($9)+1),
> >        chr(ord($14)-3), "$12", lc(chr(ord($1)+2)), reverse($14,$13),
> >        "$5", uc(chr(ord($14)-2)), "$13$14", chr(ord($9)-1), "$5",
> >        uc(chr(ord($7)+3)), "$10", chr(ord($10)+2),chr(ord($9)-2),
> >        reverse($14,$13), "\n"; }
> 
> Nope. Sorry. Not a one.
> 
> - --
> my $name=join('',reverse(split(//,'Benjamin "Snowhare" Franz')));
> $_='024e046b794c446f25423a6375477d6c14450a39447a07637e';
> s/(..)/push(@ARGV,hex($1))/eg;while($_=chop $name){
> $_=ord^shift;$_+=$a;$_%=108;print chr(($a=$_)+10)}

The above is interesting :]


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

Date: Tue, 27 Oct 1998 13:42:15 -0500
From: Dan Boorstein <danboo@negia.net>
Subject: Re: RFC - Signature
Message-Id: <36361407.F82F7ACA@negia.net>

Bill Jones, FCCJ Webmaster wrote:
> 
> Anybody have ideas about shortening this a bit?

[snip]

> $perlRulez = "FCCJ Webmaster";
> if ($perlRulez =~ /(F)(C)(C)(J)( )(W)(e)(b)(m)(a)(s)(t)(e)(r)/) {
>     print "$4", chr(ord($12)+1), "$11$12$5", uc($10), chr(ord($9)+1),
>         chr(ord($14)-3), "$12", lc(chr(ord($1)+2)), reverse($14,$13),
>         "$5", uc(chr(ord($14)-2)), "$13$14", chr(ord($9)-1), "$5",
>         uc(chr(ord($7)+3)), "$10", chr(ord($10)+2),chr(ord($9)-2),
>         reverse($14,$13), "\n"; }

sure, how 'bout:

print "Just Another Perl Hacker\n"

;)

-- 
Dan Boorstein   home: danboo@negia.net  work: danboo@y-dna.com

 "THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
                         - Cosmic AC


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

Date: Tue, 27 Oct 1998 12:56:08 -0800
From: Bill Jones <bill@fccj.org>
Subject: Re: RFC - Signature
Message-Id: <36363368.9F080687@fccj.org>

Dan Boorstein wrote:
> 
> Bill Jones, FCCJ Webmaster wrote:
> >
> > Anybody have ideas about shortening this a bit?
> 
> [snip]
> 
> > $perlRulez = "FCCJ Webmaster";
> > if ($perlRulez =~ /(F)(C)(C)(J)( )(W)(e)(b)(m)(a)(s)(t)(e)(r)/) {
> >     print "$4", chr(ord($12)+1), "$11$12$5", uc($10), chr(ord($9)+1),
> >         chr(ord($14)-3), "$12", lc(chr(ord($1)+2)), reverse($14,$13),
> >         "$5", uc(chr(ord($14)-2)), "$13$14", chr(ord($9)-1), "$5",
> >         uc(chr(ord($7)+3)), "$10", chr(ord($10)+2),chr(ord($9)-2),
> >         reverse($14,$13), "\n"; }
> 
> sure, how 'bout:
> 
> print "Just Another Perl Hacker\n"
> 
> ;)
> 
> --
> Dan Boorstein   home: danboo@negia.net  work: danboo@y-dna.com
> 
>  "THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
>                          - Cosmic AC

That's cute :]  and that sums up what perl is about!
Keepin' it simple :]

-Sneex-


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

Date: Tue, 27 Oct 1998 11:23:03 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: RFC - Signature
Message-Id: <MPG.109fbd762bb96276989840@nntp.hpl.hp.com>

In article <36363368.9F080687@fccj.org> on Tue, 27 Oct 1998 12:56:08 -
0800, Bill Jones <bill@fccj.org> says...
> Dan Boorstein wrote:
> > Bill Jones, FCCJ Webmaster wrote:
> > > Anybody have ideas about shortening this a bit?
> > [snip]
> > sure, how 'bout:
> > print "Just Another Perl Hacker\n"
> > ;)
> That's cute :]  and that sums up what perl is about!
> Keepin' it simple :]

Randal Schwartz has already posted a variant of Dan's code many times, 
but with a comma after 'Hacker', so I guess Dan's suggestion counts as 
original.  It certainly has fewer characters than any other approach.  
:-)

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


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

Date: 27 Oct 1998 12:46:39 -0500
From: Uri Guttman <uri@fastengines.com>
To: Schubert Juergen <jschubert@syskonnect.de>
Subject: Re: socket connection via udp
Message-Id: <saryaq1kidc.fsf@camel.fastserv.com>

>>>>> "SJ" == Schubert Juergen <jschubert@syskonnect.de> writes:

  SJ> Hi everybody I would like to create a socket connection via udp
  SJ> from a client to a server.  How can I create a timeout if the
  SJ> receive from the server fail (may be the server is down)?

this is not possible. connected sockets use TCP. UDP is a datagram
protocol without connections. so which do you want? and is this a perl
question? perl is not mentioned anywhere above.

in any case check out IO::Socket to do socket stuff in perl.

uri


-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: 27 Oct 1998 19:00:40 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: socket connection via udp
Message-Id: <71558o$gov12@mercury.adc.com>

In article <3635EF0C.EA4EE99A@syskonnect.de>,
Schubert Juergen  <jschubert@syskonnect.de> wrote:
>Hi everybody
>
>I would like to create a socket connection via udp from a client to a
>server.
>How can I create a timeout if the receive from the server fail (may be
>the server is down)?

Read about the "alarm" function in perlfunc.  I think that will do 
what you want.

-- 
 _____ 
|///  |   Brand Hilton  bhilton@adc.com
|  ADC|   ADC Telecommunications, ATM Transport Division
|_____|   Richardson, Texas


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

Date: 27 Oct 1998 13:12:44 -0600
From: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: System command (why a LIST??)
Message-Id: <7155vc$m8k@fohnix.metronet.com>

) Jete Software Inc. wrote:
) > 
) > I notice in the Camel book (pg 230) that the system takes a LIST argument.
) > Almost everytime that I have seen it in people's code they have coded it
) > as a single scalar string  system("cp /etc/hosts /etc/hosts.BAK").

Dave Barnett <barnett@houston.Geco-Prakla.slb.com> writes:
) Sure.  The advantage of a list context over scalar is that in list
) context, perl will attempt to execute the command directly, without
) spawning an external shell.  There are a few conditions under which perl
) will always fork a child, one of which is for globs (check DejaNews for
) the others).

Close.

system() with more than one argument _never_ uses the shell to
interpret the command line [except on some systems, especially
those without fork() where we don't have much choice].  But that
doesn't mean that Perl does the command itself without fork()ing,
just that Perl fork()s and exec()s the requested program directly,
without an external shell inbetween.  So the command is run in a
child process to Perl, not a grandchild process.

This has several advantages:

    No need to quote anything:
	Spaces, special characters (anything but '\0'), whatever you
	want can go in the arguments you pass in and they will be
	perfectly preserved in the arguments that the called command
	receives.
    No shell means tons of security holes disappear.
    More direct access to return status of command:
	If the child dies due to a signal, then the shell would
	exit with a value that is some interpretation of this and
	it can be difficult to be sure that the child died due to
	a signal and which one.
    Know the PID of the command so can send signals directly to it.

This has some disadvantages:

    No redirecting by just saying ">somefile", etc.
    No putting into background by just saying "&" on end.
    No expanding of wildcards.
    etc.

system() with a single argument will still skip using an external shell
to interpet the command line if:

    The command doesn't start with ". " nor "exec ".
    There is no "=" in the first word of the string.
and
    None of the following characters appear in the string:
	$ & * ( ) { } [ ] ' " ; \ | ? < > ~ ` \n

See C<=item exec> in perlsub.pod and do_exec() in doio.c for more info.
-- 
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: 27 Oct 1998 19:43:51 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: System command (why a LIST??)
Message-Id: <7157pn$5ll$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Tye McQueen
<tye@fohnix.metronet.com>],
who wrote in article <7155vc$m8k@fohnix.metronet.com>:
> system() with more than one argument _never_ uses the shell to
> interpret the command line [except on some systems, especially
> those without fork() where we don't have much choice].  

You are slightly off the key here.  Absense of fork() is an
*advantage* in the case of system()/friends, say, open(A, 'a |') can
actually report the absense of the command 'a'.

The reason (modulo the bugs of implementations ;-) a multi-arg system()
may call a shell on some architectures is the absense of
#!-line-processing (or whatever local synonym it is) in the kernel.
Thus if Perl finds the command it runs is in fact a script, it may
need to call the shell to negotiate correct startup of the script.

> This has some disadvantages:
> 
>     No redirecting by just saying ">somefile", etc.
>     No putting into background by just saying "&" on end.
>     No expanding of wildcards.
>     etc.

One of the most important flaw of Perl's multi-arg system()/exec() is
that they do not (sic!) check for taintedness at all.


Ilya


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

Date: Tue, 27 Oct 1998 18:37:31 GMT
From: mattf@quicklink.com
Subject: Using Window-target in HTTP header not outputting to correct frame in Internet Explorer
Message-Id: <36360f3f.436305744@news.quicklink.com>

Hi,

I've created a subroutine that should place its output into a target
frame as specified.  The subroutine below is inside an nph-cgi script,
and everything works fine when the client is Netscape.  In Explorer,
the script outputs to the same frame.  If Explorer does not understand
"Window-target", then what does it receive back when it makes requests
that target frames?  Unfortunately I don't have the ability to capture
http requests, or I could find out.  I would appreciate any help in
this matter.  Thank you.

Matt Flaherty

# ------------------------------------------------------------
sub errorSub {
print "HTTP/1.0 200 OK\n";
print "Window-target: $win\n";
print "Content-type: text/html\n\n";
print <<EOF;

<HTML>
<HEAD><TITLE>Error</TITLE>
</HEAD>

<BODY BGCOLOR="#FFFFFF">
<H1>Error:</H1>
This script has not been executed from the proper form.

</BODY>
</HTML>

EOF
exit;
}


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 4084
**************************************

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