[32415] in Perl-Users-Digest
Perl-Users Digest, Issue: 3682 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 3 06:09:35 2012
Date: Thu, 3 May 2012 03:09:09 -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 Thu, 3 May 2012 Volume: 11 Number: 3682
Today's topics:
Re: First Commercial Perl Program <m@rtij.nl.invlalid>
Re: John Carmack glorifying functional programing in 3k <miguel.a.guedes@gmail.com>
Re: John Carmack glorifying functional programing in 3k jaialai.technology@gmail.com
Re: John Carmack glorifying functional programing in 3k <tfb@tfeb.org>
Re: John Carmack glorifying functional programing in 3k <rtomek@ceti.pl>
Re: John Carmack glorifying functional programing in 3k <pjb@informatimago.com>
Re: Quick Question on Including Files <ben@morrow.me.uk>
Re: Quick Question on Including Files <artmerar@yahoo.com>
Re: Quick Question on Including Files (Tim McDaniel)
Re: Quick Question on Including Files (Tim McDaniel)
Re: Quick Question on Including Files <ben@morrow.me.uk>
Re: Quick Question on Including Files <ben@morrow.me.uk>
Re: Quick Question on Including Files <ben@morrow.me.uk>
substr documentation in perldoc <Athanasius@invalid>
Re: substr documentation in perldoc <xemoth@gmail.com>
Re: substr documentation in perldoc <jurgenex@hotmail.com>
Webhosting, Domain Name, Data Center Cyprus, Hosting Se <postcy123@gmail.com>
Re: Why does this code works without cat ? <whynot@pozharski.name>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 2 May 2012 14:40:27 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: First Commercial Perl Program
Message-Id: <rim779-rp.ln1@news.rtij.nl>
On Tue, 01 May 2012 23:09:02 +0100, Ben Morrow wrote:
> Quoth Martijn Lievaart <m@rtij.nl.invlalid>:
>> On Tue, 01 May 2012 10:55:52 -0500, Reini Urban wrote:
>>
>> > 1. password in cleartext for ssh?
>> > never do that. even if the customer is to stupid to understand that,
>> > you should just refuse to do that and ssh-copy-id instead.
>>
>> And what does a private key stored in plaintext buy you over a password
>> stored in plaintext?
>>
>> (Yes, there is an advantage, but it is not obvious. Do you know it?)
>
> It can be revoked, obviously. This means, as a corollary, that you
> should never use the same private key on more than one machine.
A password can be revoked as well, but it is easier to use multiple keys
on one account and then revoke only one of them. True, hadn't thought of
that myself.
What I was thinking of, was that sshd will ensure tight file permissions
on the private key, while a config file containing a password has a good
chance of ending up world readable.
> As a matter of general security, a randomly-generated key is also not
> subject to dictionary attacks, which a user-chosen password generally
> will be. This is not relevant here, of course.
It might be, people do stupid things all the time. So yes,this is another
good point in favor of using keys over passwords.
> (In general I don't consider ssh keys particularly secure, and would
> rather use Kerberos, but that isn't usually possible across
> authentication domains.)
I think all schemes have advantages and disadvantages and Kerberos is a
scheme with the disadvantage that it is much more difficult to set up
correctly. So unless you do the hard work once and then can plug into
your existing Kerberos infra from then on, I don't find Kerberos
particularly manageable. And unmanageable equals unsecure.
M4
------------------------------
Date: Wed, 02 May 2012 11:55:35 +0100
From: Miguel Guedes <miguel.a.guedes@gmail.com>
Subject: Re: John Carmack glorifying functional programing in 3k words
Message-Id: <4fa11386$0$11126$88263eea@blocknews.net>
On 27/04/12 03:11, Xah Lee wrote:
> John Carmack glorifying functional programing in 3k words
>
> http://www.altdevblogaday.com/2012/04/26/functional-programming-in-c/
>
> where was he ten years ago?
>
> O, and btw, i heard that Common Lispers don't do functional
> programing, is that right?
>
> Fuck Common Lispers. Yeah, fuck them. One bunch of Fuckfaces. (and
> Fuck Pythoners. Python fucking idiots.)
>
> O, don't forget,
>
> 〈Programing: What are OOP's Jargons and Complexities (Object Oriented
> Program as Functional Program)〉
> http://xahlee.org/Periodic_dosage_dir/t2/oop.html
>
> please you peruse of it.
I'm not a 'Common Lisper' or a 'Pythoner' so I'm not directly or
personally affected by your retarded and offensive comment. However, who
the fuck do you think you are to post stuff of this nature? (I believe)
I'll understand if you've got some sort of psychological issue affecting
your behaviour.
------------------------------
Date: Wed, 02 May 2012 10:44:36 -0400
From: jaialai.technology@gmail.com
Subject: Re: John Carmack glorifying functional programing in 3k words
Message-Id: <7777f$4fa14855$813f0835$20772@news.eurofeeds.com>
> I'm not a 'Common Lisper' or a 'Pythoner' so I'm not directly or
> personally affected by your retarded and offensive comment. However, who
> the fuck do you think you are to post stuff of this nature? (I believe)
> I'll understand if you've got some sort of psychological issue affecting
> your behaviour.
OP lives out of his car and his main source of income seems to be ad
revenue from his website.
He may be nuts be he is pretty smart and some of the articles he has up
there are worth reading. Still, he has to promote it in some way and by
constantly posting these sorts of things he brings people to his site.
I'm honestly impressed he can survive this way so I am willing to
ignore or maybe killfile his postings and leave him be.
------------------------------
Date: Wed, 2 May 2012 16:30:23 +0100
From: Tim Bradshaw <tfb@tfeb.org>
Subject: Re: John Carmack glorifying functional programing in 3k words
Message-Id: <jnrjuf$3fr$1@dont-email.me>
On 2012-05-02 14:44:36 +0000, jaialai.technology@gmail.com said:
> He may be nuts
But he's right: programmers are pretty much fuckwits[*]: if you think
that's not true you are not old enough.
[*] including me, especially.
------------------------------
Date: Wed, 2 May 2012 17:31:33 +0200
From: Tomasz Rola <rtomek@ceti.pl>
Subject: Re: John Carmack glorifying functional programing in 3k words
Message-Id: <Pine.LNX.4.64.1205021723330.10991@tau.ceti.pl>
On Wed, 2 May 2012, jaialai.technology@gmail.com wrote:
> > I'm not a 'Common Lisper' or a 'Pythoner' so I'm not directly or
> > personally affected by your retarded and offensive comment. However, who
> > the fuck do you think you are to post stuff of this nature? (I believe)
> > I'll understand if you've got some sort of psychological issue affecting
> > your behaviour.
> OP lives out of his car and his main source of income seems to be ad
> revenue from his website.
> He may be nuts be he is pretty smart and some of the articles he has up
> there are worth reading. Still, he has to promote it in some way and by
> constantly posting these sorts of things he brings people to his site.
> I'm honestly impressed he can survive this way so I am willing to
> ignore or maybe killfile his postings and leave him be.
He may be smart but obviously hasn't figured out this yet: positive aura
drives more people and more permamently towards you. Perhaps he should
develop an alter ego that could stand side by side with Dalai Lama and see
which one gets more attention.
Regards,
Tomasz Rola
--
** A C programmer asked whether computer had Buddha's nature. **
** As the answer, master did "rm -rif" on the programmer's home **
** directory. And then the C programmer became enlightened... **
** **
** Tomasz Rola mailto:tomasz_rola@bigfoot.com **
------------------------------
Date: Thu, 03 May 2012 10:06:42 +0200
From: "Pascal J. Bourguignon" <pjb@informatimago.com>
Subject: Re: John Carmack glorifying functional programing in 3k words
Message-Id: <874nrxn0x9.fsf@kuiper.lan.informatimago.com>
Tim Bradshaw <tfb@tfeb.org> writes:
> On 2012-05-02 14:44:36 +0000, jaialai.technology@gmail.com said:
>
>> He may be nuts
>
> But he's right: programmers are pretty much fuckwits[*]: if you think
> that's not true you are not old enough.
>
> [*] including me, especially.
You need to watch:
http://blog.ted.com/2012/02/29/the-only-way-to-learn-to-fly-is-to-fly-regina-dugan-at-ted2012/
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
------------------------------
Date: Wed, 2 May 2012 13:52:00 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Quick Question on Including Files
Message-Id: <g8n779-2522.ln1@anubis.morrow.me.uk>
Quoth tmcd@panix.com:
> In article <52j679-mus1.ln1@anubis.morrow.me.uk>,
> Ben Morrow <ben@morrow.me.uk> wrote:
> > if (-e $config) {
> > %SERVICES = do $config;
> > }
> >
> >Then you want your config file to *just* contain the data structure,
> >without any variable assignment, like this
> >
> > tactical => {
> > service => "tactical",
> > url => "tacticaltrader",
> > ...
> > },
> > ...
>
> If you use this syntax, I think the parentheses around the list have
> to be supplied somewhere, though I've not tested it.
I, on the other hand, *have* tested it, and they do not.
The parens are required on the RHS of a list assignment because
assignment binds tighter than comma. (This is because comma is sometimes
pretending to be the C comma operator, and is not helpful IMHO.) The RHS
of that assignment is a single function call ('do' is a builtin, but it
parses like a function call), so no parens are required. The expression
inside the file is a single statement returning a list, so again no
parens are required.
> I looked at perlfunc do and came up with this test program.
> It has an error-checking scheme that nearly requires a scalar return
> value (otherwise, an error return in
> my %x = (do "./103a.pl");
> would cause warnings
> Odd number of elements in hash assignment
> Use of uninitialized value in list assignment
> and result in a hash of
> '' => undef
> ).
You can fix that with
my @s = do ...;
defined $s[0] or ...;
@s > 1 or $s[0] or ...;
my %SERVICES = @s;
though TBH it's probably cleaner to have a hashref in the file rather
than a bare hash. I was not assuming the OP would know what to do with a
$SERVICES hashref.
> #! /usr/bin/perl
> use strict;
> use warnings;
> use Data::Dumper;
> my $x = do "./103a.pl";
> warn "couldn't parse file: $@" if $@;
> warn "couldn't do file: $!" unless defined $x;
> warn "couldn't run file" unless $x;
> my %x = %{$x};
That's a bad plan, if you can avoid it. Copying a hash like that will
not just copy but also rehash all the elements. Just use the ref, or use
Data::Alias.
Ben
------------------------------
Date: Wed, 2 May 2012 06:03:38 -0700 (PDT)
From: ExecMan <artmerar@yahoo.com>
Subject: Re: Quick Question on Including Files
Message-Id: <6d5dc901-ecfc-4c5f-b4bb-5c9ba7684c7e@h20g2000yqd.googlegroups.com>
On May 2, 1:41=A0am, t...@panix.com (Tim McDaniel) wrote:
> In article <52j679-mus1....@anubis.morrow.me.uk>,
> Ben Morrow =A0<b...@morrow.me.uk> wrote:
>
> > =A0 =A0if (-e $config) {
> > =A0 =A0 =A0 =A0%SERVICES =3D do $config;
> > =A0 =A0}
>
> >Then you want your config file to *just* contain the data structure,
> >without any variable assignment, like this
>
> > =A0 =A0tactical =A0=3D> {
> > =A0 =A0 =A0 =A0service =3D> "tactical",
> > =A0 =A0 =A0 =A0url =A0 =A0 =3D> "tacticaltrader",
> > =A0 =A0 =A0 =A0...
> > =A0 =A0},
> > =A0 =A0...
>
> If you use this syntax, I think the parentheses around the list have
> to be supplied somewhere, though I've not tested it. =A0That is, I think
> it has to be either
>
> =A0 =A0 =A0 =A0 %SERVICES =3D (do $config);
>
> or the config file has to be
>
> =A0 =A0 (
> =A0 =A0 =A0 =A0 tactical =A0=3D> {
> =A0 =A0 =A0 =A0 =A0 =A0 service =3D> "tactical",
> =A0 =A0 =A0 =A0 =A0 =A0 url =A0 =A0 =3D> "tacticaltrader",
> =A0 =A0 =A0 =A0 =A0 =A0 ...
> =A0 =A0 =A0 =A0 },
> =A0 =A0 =A0 =A0 ...
> =A0 =A0 )
>
> I looked at perlfunc do and came up with this test program.
> It has an error-checking scheme that nearly requires a scalar return
> value (otherwise, an error return in
> =A0 =A0 my %x =3D (do "./103a.pl");
> would cause warnings
> =A0 =A0 Odd number of elements in hash assignment
> =A0 =A0 Use of uninitialized value in list assignment
> and result in a hash of
> =A0 =A0 '' =3D> undef
> ).
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> #! /usr/bin/perl
> use strict;
> use warnings;
> use Data::Dumper;
> my $x =3D do "./103a.pl";
> warn "couldn't parse file: $@" if $@;
> warn "couldn't do file: $!" =A0 =A0unless defined $x;
> warn "couldn't run file" =A0 =A0 =A0 unless $x;
> my %x =3D %{$x};
> print Data::Dumper->Dump([\%x], [qw[x]]), "\n";
> exit 0;
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> [this is 103a.pl]
>
> use strict;
> use warnings;
> {
> =A0a =3D> 'b',
> =A0c =3D> 'd',
>
> }
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> This does error checking: see what happens if you put a syntax error
> in the included file (here, 103a.pl).
>
> It does not require "our" variables.
>
> --
> Tim McDaniel, t...@panix.com
Perl is just so strange. And several attempts I got it to work like
this:
my %SERVICES =3D do "$CONFIG_DIR/config";
Interesting how this did NOT work:
my %SERVICES;
if (-e "hash_config") {
do "hash_config";
}
Not sure of the difference....
------------------------------
Date: Wed, 2 May 2012 15:40:13 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: Quick Question on Including Files
Message-Id: <jnrkgt$lcp$1@reader1.panix.com>
In article <g8n779-2522.ln1@anubis.morrow.me.uk>,
Ben Morrow <ben@morrow.me.uk> wrote:
>
>Quoth tmcd@panix.com:
>> In article <52j679-mus1.ln1@anubis.morrow.me.uk>,
>> Ben Morrow <ben@morrow.me.uk> wrote:
>> > if (-e $config) {
>> > %SERVICES = do $config;
>> > }
>> >
>> >Then you want your config file to *just* contain the data
>> >structure, without any variable assignment, like this
>> >
>> > tactical => {
>> > service => "tactical",
>> > url => "tacticaltrader",
>> > ...
>> > },
>> > ...
>>
>> If you use this syntax, I think the parentheses around the list
>> have to be supplied somewhere, though I've not tested it.
>
>I, on the other hand, *have* tested it, and they do not.
>
>The parens are required on the RHS of a list assignment because
>assignment binds tighter than comma. (This is because comma is sometimes
>pretending to be the C comma operator, and is not helpful IMHO.) The RHS
>of that assignment is a single function call ('do' is a builtin, but it
>parses like a function call), so no parens are required. The expression
>inside the file is a single statement returning a list, so again no
>parens are required.
AH! Thank you. It works the same basic way as
#! /usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
sub foo { 19, 20, 21 }
my @a = foo();
print Dumper(\@a), "\n";
my $a = foo();
print Dumper($a), "\n";
exit 0;
printing, first, [ 19, 20, 21 ], and second, just 21.
>I was not assuming the OP would know what to do with a
>$SERVICES hashref.
...
>> my %x = %{$x};
>
>That's a bad plan, if you can avoid it. Copying a hash like that will
>not just copy but also rehash all the elements.
Yes, but I was not assuming the OP would know what to do with a
$SERVICES hashref. Unless it's large or being done a lot, if you're
not familiar with it it's simpler to just stick it into the
appropriate aggregate.
>or use Data::Alias.
It should be noted that that does not appear to be built in to Perl.
--
Tim McDaniel, tmcd@panix.com
------------------------------
Date: Wed, 2 May 2012 15:43:04 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: Quick Question on Including Files
Message-Id: <jnrkm8$lcp$2@reader1.panix.com>
In article <6d5dc901-ecfc-4c5f-b4bb-5c9ba7684c7e@h20g2000yqd.googlegroups.com>,
ExecMan <artmerar@yahoo.com> wrote:
>Perl is just so strange. And several attempts I got it to work like
>this:
>
>my %SERVICES = do "$CONFIG_DIR/config";
>
>Interesting how this did NOT work:
>
>
>Not sure of the difference....
Leaving aside the obvious difference in file names:
In the example config file, there was just a list of data like
thumper => 'rabbit',
or whatever. Nowhere was it being assigned to a variable.
>my %SERVICES;
>
>if (-e "hash_config") {
> do "hash_config";
>
>}
would just evaluate it and throw it away. If you changed the "do" to
> %SERVICES = do "hash_config";
it should have worked.
Though I really think it better that your code not ignore error
messages.
--
Tim McDaniel, tmcd@panix.com
------------------------------
Date: Wed, 2 May 2012 17:33:27 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Quick Question on Including Files
Message-Id: <n74879-2m92.ln1@anubis.morrow.me.uk>
Quoth ExecMan <artmerar@yahoo.com>:
>
> Perl is just so strange. And several attempts I got it to work like
> this:
>
> my %SERVICES = do "$CONFIG_DIR/config";
>
> Interesting how this did NOT work:
>
> my %SERVICES;
>
> if (-e "hash_config") {
> do "hash_config";
>
> }
>
> Not sure of the difference....
'do' returns the value it got from the file. Your second example does
nothing with this value, so it just disappears into the aether. Your
first example assigns it to %SERVICES, which is where you want it.
Perhaps you are getting confused by the fact you have an assignment to a
variable called %SERVICES in the config file? As I tried to explain
before (but perhaps I wasn't very clear), this is *not* the same
variable as the 'my %SERVICES' in the main program. The whole point of
'my' is that you can have a 'my %SERVICES' in one file, and a different
'my %SERVICES' in another file, and they won't interfere with each
other.
Ben
------------------------------
Date: Wed, 2 May 2012 17:39:47 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Quick Question on Including Files
Message-Id: <jj4879-2m92.ln1@anubis.morrow.me.uk>
Quoth tmcd@panix.com:
> In article <g8n779-2522.ln1@anubis.morrow.me.uk>,
> Ben Morrow <ben@morrow.me.uk> wrote:
>
> >I was not assuming the OP would know what to do with a
> >$SERVICES hashref.
> ...
> >> my %x = %{$x};
> >
> >That's a bad plan, if you can avoid it. Copying a hash like that will
> >not just copy but also rehash all the elements.
>
> Yes, but I was not assuming the OP would know what to do with a
> $SERVICES hashref. Unless it's large or being done a lot, if you're
> not familiar with it it's simpler to just stick it into the
> appropriate aggregate.
Touche :).
> >or use Data::Alias.
>
> It should be noted that that does not appear to be built in to Perl.
No. There was some work in that direction a while ago (the core SvTYPE
SVt_BIND has been reserved for this purpose since IIRC 5.10), but it
doesn't appear to have gone anywhere.
Ben
------------------------------
Date: Wed, 2 May 2012 17:43:38 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Quick Question on Including Files
Message-Id: <qq4879-2m92.ln1@anubis.morrow.me.uk>
Quoth tmcd@panix.com:
> >
> > %SERVICES = do "hash_config";
> it should have worked.
>
> Though I really think it better that your code not ignore error
> messages.
It's a little annoying here that do doesn't return an empty list in list
context if it fails. (If it were a user-defined sub, I would be saying
'don't use C<return undef;>, just use C<return;>'.) After all, the OP is
already expecting to end up with an empty hash if the file isn't there,
and treating 'file won't compile' the same as 'file not found' is a
perfectly sensible strategy.
Ben
------------------------------
Date: Thu, 3 May 2012 16:24:02 +1000
From: "Athanasius" <Athanasius@invalid>
Subject: substr documentation in perldoc
Message-Id: <4fa224b5$0$2349$c3e8da3$88b277c5@news.astraweb.com>
Hi,
Searching perldoc (Perl 5 version 14.1) for the built-in 'substr' function
gives:
> substr EXPR,OFFSET,LENGTH,REPLACEMENT
> substr EXPR,OFFSET,LENGTH
> substr EXPR,OFFSET
>
> Extracts a substring out of EXPR and returns it. First character is at
> offset 0 ...
Is "0" a typo for "OFFSET" -- that is, should the first sentence be: "First
character is at offset OFFSET..." -- or am I just confused?
Thanks,
Athanasius <°(((>< contra mundum
------------------------------
Date: Wed, 2 May 2012 23:33:30 -0700 (PDT)
From: Owen <xemoth@gmail.com>
Subject: Re: substr documentation in perldoc
Message-Id: <637511.768.1336026810758.JavaMail.geo-discussion-forums@pbpf6>
On Thursday, May 3, 2012 4:24:02 PM UTC+10, Athanasius wrote:
> Hi,
>=20
> Searching perldoc (Perl 5 version 14.1) for the built-in 'substr' functio=
n=20
> gives:
>=20
> > substr EXPR,OFFSET,LENGTH,REPLACEMENT
> > substr EXPR,OFFSET,LENGTH
> > substr EXPR,OFFSET
> >
> > Extracts a substring out of EXPR and returns it. First character is=
at=20
> > offset 0 ...
>=20
No, that is 0, the way you count is 0,1,2, .... so the first character is =
at position 0. If the offset is say 3, then the string is taken from starti=
ng at the 4th character.
Owen
> Is "0" a typo for "OFFSET" -- that is, should the first sentence be: "Fir=
st=20
> character is at offset OFFSET..." -- or am I just confused?
>=20
> Thanks,
> Athanasius <=B0(((>< contra mundum
------------------------------
Date: Wed, 02 May 2012 23:39:56 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: substr documentation in perldoc
Message-Id: <ht94q75joo1mj1hc08s74sscggme2gmjri@4ax.com>
"Athanasius" <Athanasius@invalid> wrote:
>Searching perldoc (Perl 5 version 14.1) for the built-in 'substr' function
>gives:
>
>> substr EXPR,OFFSET,LENGTH,REPLACEMENT
>> substr EXPR,OFFSET,LENGTH
>> substr EXPR,OFFSET
>>
>> Extracts a substring out of EXPR and returns it. First character is at
>> offset 0 ...
>
>Is "0" a typo for "OFFSET" -- that is, should the first sentence be: "First
>character is at offset OFFSET..." -- or am I just confused?
Read that as "first character _of_the_original_string_ is at offset 0,
i.e. if you want to retrieve the first character of the original string,
then you have to use offset 0.
jue
------------------------------
Date: Wed, 2 May 2012 06:08:32 -0700 (PDT)
From: "Webhosting, Domain Name, Data Center Cyprus, Hosting Services" <postcy123@gmail.com>
Subject: Webhosting, Domain Name, Data Center Cyprus, Hosting Services
Message-Id: <6eb5442f-9538-4a23-811c-bbf2a9f72f5e@r32g2000yqj.googlegroups.com>
Webhosting =96 postcy - a leading web hosting company. We offer
webhosting, domain name, hosting services, cyprus domain, domain names
cyprus at affordable cost.
for more details please contact : http://www.postcy.com/
------------------------------
Date: Wed, 02 May 2012 21:17:48 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Why does this code works without cat ?
Message-Id: <slrnjq2uic.tuu.whynot@orphan.zombinet>
with <1qal69-cbj1.ln1@anubis.morrow.me.uk> Ben Morrow wrote:
> Quoth Eric Pozharski <whynot@pozharski.name>:
*SKIP*
>> The only reason for this could be POSIX. Any reference, please?
> Well, if you insist:
>| If more than one redirection operator is specified with a command,
>| the order of evaluation is from beginning to end.
>|
>| A failure to open or create a file shall cause a redirection to fail.
>|
>| 2.7.1 Redirecting Input
>|
>| Input redirection shall cause the file whose name results from the
>| expansion of word to be opened for reading on the designated file
>| descriptor, or standard input if the file descriptor is not
>| specified.
After reading and further research I must admit that's the only relevant
part. Now I can say, that bash-people and zsh-people read that
differently. POSIX, at least four years ago, says nothing what to do if
one FD is redirected more than once. "the order of evaluation is from
beginning to end" doesn't suppose that what's already evaluated should
be dropped. I've got to conclusion (and I'm not interested in
discussing this with bash-people) that both shells, bash and zsh, are
POSIX compliant.
However, I dare to comment a bit more. There're three concurent ways to
maintain STDIN for commands.
First, what cat(1) does, in essence, is turning files into clean
bytestream. OTOH, there's that puristic proverb about
useless-use-of-cat. And that proverb is mantra. Tell me, shell
wizards, what is more pure:
cat filename | grep word
or
grep -h word filename
And all that bytestream BS is relevant as long as cat(1) is fed with
filenames. Because,
Second comes redirection. It has bonuses, but (I stand corrected) it
comes with price. And that price is so huge that it renders redirection
useless. Isn't this elegant:
cat <<<"### /etc/hosts.allow ###" /etc/hosts.allow \
<<<"### /etc/hosts.deny ###" /etc/hosts.deny | lp
It's not, because it's not portable. What we have here is bash sneaking
it's features and limitations under disguise of compatibility. Good
news is that shell is so long forgotten that it doesn't harm anyone
anymore.
Third is command line tail. Well, we're supposedly talking Perl here,
it's an *interpreted* script, I can do whatever I want with that script.
I just need filenames.
Shortly, zsh wins, bash is lame, we all lose, and now I feel much better.
*CUT*
--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 V11 Issue 3682
***************************************