[24693] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6852 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 10 14:06:11 2004

Date: Tue, 10 Aug 2004 11:05: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           Tue, 10 Aug 2004     Volume: 10 Number: 6852

Today's topics:
    Re: Can somebody explain? <pinyaj@rpi.edu>
    Re: catch error code from system() <tadmc@augustmail.com>
    Re: creating shell scripts using #!/usr/local/env perl nobull@mail.com
    Re: Expression Problem <gnari@simnet.is>
    Re: Expression Problem <Some.One@hotmail.com>
    Re: Expression Problem <bernard.el-haginDODGE_THIS@lido-tech.net>
    Re: Expression Problem <gnari@simnet.is>
    Re: Input from subprocess called using open() buffered? <"g r a e m e b [at] c a d e n c e [dot] c o m">
    Re: Joining 2 strings <bowsayge@nomail.afraid.org>
    Re: Joining 2 strings <abodeman@yahoo.com>
    Re: News::Scan question <segraves_f13@mindspring.com>
    Re: News::Scan question <segraves_f13@mindspring.com>
    Re: split inconsistency- why? (Sara)
    Re: split inconsistency- why? (Sara)
    Re: split inconsistency- why? <uri@stemsystems.com>
    Re: split inconsistency- why? <tadmc@augustmail.com>
    Re: split inconsistency- why? <peter@semantico.com>
    Re: split inconsistency- why? <xx087@freenet.carleton.ca>
    Re: split inconsistency- why? ctcgag@hotmail.com
    Re: split inconsistency- why? <nobull@mail.com>
    Re: Statistics for comp.lang.perl.misc <mr@sandman.net>
    Re: Statistics for comp.lang.perl.misc <tadmc@augustmail.com>
    Re: Statistics for comp.lang.perl.misc <mr@sandman.net>
    Re: Statistics for comp.lang.perl.misc <jurgenex@hotmail.com>
    Re: Statistics for comp.lang.perl.misc <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 10 Aug 2004 09:13:46 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: Can somebody explain?
Message-Id: <Pine.SGI.3.96.1040810091227.20284A-100000@vcmr-64.server.rpi.edu>

On Tue, 10 Aug 2004, Brian McCauley wrote:

>> $cchat = qr/((\W)?(\*?\*?\w+)\s*($temp))/;
>
>This defines another pre-complied regex that matches something followed 
>by a ballenced (...).
>
>The "something" is rather odd but there's no point trying to explain it. 

I'd say it looks like it's matching a C function definition (although
ignoring the return *type* of the function, and only capturing the level
of dereferencing needed).  But it does a poor job; it's too specific in
its formulation.

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
RPI Corporation Secretary   %  have long ago been overpaid?
http://japhy.perlmonk.org/  %  
http://www.perlmonks.org/   %    -- Meister Eckhart




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

Date: Tue, 10 Aug 2004 07:54:57 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: catch error code from system()
Message-Id: <slrnchhhd1.3tt.tadmc@magna.augustmail.com>

justme <eight02645999@yahoo.com> wrote:

> how can i catch the return code of the java prog reliably ? 


Please do not ask thousands of people to read the docs to you.


   perldoc -f system


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 10 Aug 2004 10:47:04 -0700
From: nobull@mail.com
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <4dafc536.0408100947.55f4476d@posting.google.com>

Abigail <abigail@abigail.nl> wrote in message news:<slrnchfi3k.ec9.abigail@alexandra.abigail.nl>...
> Brian McCauley (nobull@mail.com) wrote on MMMCMXCVI September MCMXCIII in
> <URL:news:cf8f3c$2kb$1@slavica.ukpost.com>:
> ##  Abigail wrote:
> ## > 
> ## > The point is that assuming that "env" is present, and has the same
> ## > location on all system doesn't differ from assuming that "perl" is
> ## > present and has the same location on all machines.
> ##  
> ##  While it is conceptually the same it is in practice more portable.
> ##  
> ##  One is very unlikely to ever encounter a unix-like platform where 
> ##  /usr/bin/env isn't there.
> ##  
> ##  One is very likely to encounter a unix-like platform where preferred 
> ##  perl interpreter is somewhere other than /usr/bin
> 
> 
> Hmmm, and 'env' is magical and just knows which of the installed perl
> interpreters on a system is the preferred one?

No, when one says "the preferred foo" then it is assumed that someone
has expressed a preference in some way.  Clearly nothing can react to
an unexpressed preference. (This has nothing to do with Perl, or
indeed computers).
If I say I will buy you your preferred drink from the bar I'm not
claiming to be able to read your mind.

> Or does your "more portable" solution depend on the settings of the 
> users path?

Of course it does, that is the expression of the preference.

> If I write an application that depends on a particular version of Perl
> then [...]

 ...you are doing something quite the opposite to that which is the
topic of this thread - i.e. getting a script to use whatever Perl
interpreter the user would usually use.

> ... whatever I end up distributing will include said version of Perl,
> and it will not depend on whether 'env' is present or even whether that
> version of Perl is installed.

Unless you are shipping the operating system and the hardware too then
there will still be dependancies.  All you are doing is moving the
line where what you ship interfaces to what you require the user has
already.  Actually by shipping Perl you are probably relying on the
presence either of specific runtime libraries (and architecture) or a
compiler so you are probabaly being more presciptive.


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

Date: Tue, 10 Aug 2004 10:10:34 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Expression Problem
Message-Id: <cfa6qp$cpa$1@news.simnet.is>

"Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net> wrote in
message news:Xns954174513BF97elhber1lidotechnet@62.89.127.66...
> "gnari" <gnari@simnet.is> wrote:
>
> > "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
> > wrote in message
> > news:Xns95416783DCA6Delhber1lidotechnet@62.89.127.66...
> >> Noname <Some.One@hotmail.com> wrote:
> >>
> >> > Hi,
> >> > I have input from STDIN like $Input="1-5,6,8,10-15";
> >> > which actually needs to be interpreted as an
> >> > array=1,2,3,4,5,6,8,10,11,12,13,14,15
> >> > how can it be done,
> >>
> >>
> >> my @array = map { s/-/../; eval } split /,/, $Input;
> >
> >
> > please do not do this unless you trust the input 100% to
> > be in the format described.
> >
> > malicious input (or a mistake) can result in arbitrary code
> > execution. (think rm -R /)
>
>
> That would result in evaling "rm ..R /". ;-)

lots of destructive commands do not include a '-'.
in any case , there is no /g in your code, so this
limitation can easily be avoided.

system("ls -;rm -R /")

gnari





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

Date: Tue, 10 Aug 2004 11:09:31 GMT
From: Noname <Some.One@hotmail.com>
Subject: Re: Expression Problem
Message-Id: <L12Sc.22309$k4.435839@news1.nokia.com>

Paul GABORIT <Paul.Gaborit@invalid.invalid> wrote in
news:r7vffr5res.fsf@michelange.enstimac.fr: 

> Path:
> news2.nokia.com!news1.nokia.com!news2.nokia.com.POSTED!not-for-mail 
> Newsgroups: comp.lang.perl.misc
> Subject: Expression Problem
> From: Noname <Some.One@hotmail.com>
> User-Agent: Xnews/5.04.25
> Lines: 5
> Message-ID: <Wc%Rc.22142$g4.418525@news2.nokia.com>
> Date: Tue, 10 Aug 2004 07:56:38 GMT
> NNTP-Posting-Host: 172.21.11.70
> X-Complaints-To: newsmaster@nokia.com
> X-Trace: news2.nokia.com 1092124598 172.21.11.70 (Tue, 10 Aug 2004
> 10:56:38 EET DST) NNTP-Posting-Date: Tue, 10 Aug 2004 10:56:38 EET DST
> Organization: Nokia
> Xref: news1.nokia.com comp.lang.perl.misc:285995
> 
> Hi,
> I have input from STDIN like $Input="1-5,6,8,10-15";
> which actually needs to be interpreted as an 
> array=1,2,3,4,5,6,8,10,11,12,13,14,15
> how can it be done,

I did had a bad experience with "eval" function so I will surely aviod it , 
and use the one without it ,
thanks for your time and information


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

Date: Tue, 10 Aug 2004 13:18:54 +0200
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Expression Problem
Message-Id: <Xns954187E601E46elhber1lidotechnet@62.89.127.66>

"gnari" <gnari@simnet.is> wrote:

[...]

>> >> my @array = map { s/-/../; eval } split /,/, $Input;
>> >
>> >
>> > please do not do this unless you trust the input 100% to
>> > be in the format described.
>> >
>> > malicious input (or a mistake) can result in arbitrary code
>> > execution. (think rm -R /)
>>
>>
>> That would result in evaling "rm ..R /". ;-)
> 
> lots of destructive commands do not include a '-'.


I think you took my reply too seriously. :)


-- 
Cheers,
Bernard


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

Date: Tue, 10 Aug 2004 12:01:44 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Expression Problem
Message-Id: <cfadb7$dge$1@news.simnet.is>

"Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net> wrote in
message news:Xns954187E601E46elhber1lidotechnet@62.89.127.66...
> "gnari" <gnari@simnet.is> wrote:
>
> [...]
>
> >> >> my @array = map { s/-/../; eval } split /,/, $Input;
> >> >
> >> >
> >> > please do not do this unless you trust the input 100% to
> >> > be in the format described.
> >> >
> >> > malicious input (or a mistake) can result in arbitrary code
> >> > execution. (think rm -R /)
> >>
> >>
> >> That would result in evaling "rm ..R /". ;-)
> >
> > lots of destructive commands do not include a '-'.
>
>
> I think you took my reply too seriously. :)

that was on purpose :-)

anyways, the OP seems to have been aware of the
dangers of indiscriminate eval(), so all's well.

gnari






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

Date: Tue, 10 Aug 2004 13:17:21 +0100
From: "g r a e m e b [at] c a d e n c e [dot] c o m" <"g r a e m e b [at] c a d e n c e [dot] c o m">
Subject: Re: Input from subprocess called using open() buffered?
Message-Id: <4118bcdb@news.cadence.com>

Actually, I tell a lie - none of these work... :(

Although they receive the output at the right time, neither one of them ever 
terminates.  I tried checking for EOF on COMMAND, but either this hangs until 
EOF is actually received, or if I use fcntl to set it to nonblocking, it always 
returns EOF!

There must be a better way of doing this... I presume CVS is block-buffering 
because it's usually used across a network, but redirecting the output to a pty 
is proving somewhat troublesome!  Any help would be appreciated!

Thanks,
Graeme.

g r a e m e b [at] c a d e n c e [dot] c o m wrote:
> Success! :)
> 
> Thanks for all the replies, I managed to get two solutions which do what 
> I want, neither of which are probably correct! ;D
> 
> The first one, using raw IO::Pty, looks a little like this:
> 
> my $pty = new IO::Pty;
> my $ttyname = $pty->ttyname();
> print "Spawned tty $ttyname\n";
> open(COMMAND, "$cmd > $ttyname 2>&1|") || die "Couldn't run command";
> while(<$pty>) {
>   print ":: $_";
> }
> close($pty);
> 
> I take it that I'm supposed to run the command and direct the IO 
> manually to the pty I've opened (eg. "cvs update > /dev/pty56 2>&1")?  
> This seems to work fine, I just want to check I'm using it correctly.
> 
> I am a bit baffled as to why I need to have COMMAND as a filehandle - is 
> there a better way of doing this?  And do I need to close both $pty and 
> COMMAND? Presumably all the output is going to $pty, so I don't even 
> need COMMAND, or do I?
> 
> 
> The other method, using Expect, looked a little like this (note that I 
> hacked this up BEFORE looking at the Expect docs!):
> 
> my $process = Expect->spawn("$cmd 2>&1");
> while (<$process>) {
>   print "|| $_";
> }
> close($process);
> 
> It's more succinct than the one above, but when I looked at the docs, it 
> didn't seem to even mention being able to loop over the filehandle 
> returned (in the question about "what if I only want to get output 
> without 'expecting' anything?".  Not sure if this works by accident or 
> design!
> 
> Any code criticism welcome...
> 
> Thanks,
> Graeme.
> 
> PS.  I was running 'cvs update' (and checkout) - it does indeed have the 
> same effect if I do 'cvs update 2>&1 | cat'.  Thanks, I thought this was 
> an obscure perl thing, didn't realise other programs actually did 
> different things depending upon the output file...
> 
> 
> 510046470588-0001@t-online.de wrote:
> 
>> Brian McCauley <nobull@mail.com> writes:
>>
>>> Failing that, I Expect (hint, hint) there's something on CPAN you
>>> could use to allow Perl to fool the other process into thinking its
>>> output was going to a terminal.
>>
>>
>>
>>
>> IO::Pty, which comes with IO::Tty
>>
>> Klaus Schilling
> 
> 



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

Date: Tue, 10 Aug 2004 13:09:12 GMT
From: bowsayge <bowsayge@nomail.afraid.org>
Subject: Re: Joining 2 strings
Message-Id: <YN3Sc.19411$Jp6.3407@newsread3.news.atl.earthlink.net>

Sim said to us:

[...]
> Problems:
> 1. I cannot join/ append the 3 lines on a single line. 
[...]

This works for bowsayge:

while (scalar @lines) {
    print join " ", splice @lines, 0, 3;
    print "\n";
}

-- 
my (@str) = split //,'ttneuhb .aenpesrrJ oei wl';
my (@ndx, @arr) = qw(8 3 18 19 1 9 21 17 24 5 10 6 13 
23 2 11 15 0 12 7 14 22 4 20 16);
$arr[$ndx[$_]] = $str[$_] for (@ndx); print @arr, "\n";



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

Date: Tue, 10 Aug 2004 10:08:53 -0500
From: "Brian Kell" <abodeman@yahoo.com>
Subject: Re: Joining 2 strings
Message-Id: <opsciu03t6z772u5@pc0938>

On 9 Aug 2004 16:37:45 -0700, Sim <selena_kid@yahoo.com> wrote:

> Problems:
> 1. I cannot join/ append the 3 lines on a single line. Solutions
> posted above overwrite the 3 lines, on top of one another. This is
> described in my previous post (post #7).
>
> ...
>
> Window XP

What might be happening is this: A newline on Windows is \r\n, or CRLF, or  
"carriage return, line feed". If you take off the line feed from the end  
of each line, you still have the carriage return left over, which moves  
the cursor back to the beginning of the current line. So, if you take  
three lines and join them, you get something like this, where "\r" means a  
carriage return:

"abcdefghi\rjklmno\rpqr"

Now, if you print that string to the screen, Windows prints "abcdefghi",  
backs up to the first column, prints "jklmno", backs up to the first  
column again, and prints "pqr", so what you see on the screen is  
"pqrmnoghi". The string itself contains all the letters, and if you write  
the string to a file it will contain all the letters, but because of the  
embedded carriage returns if you print the string to the screen it appears  
to have been overwritten.

If you use the length function to get the number of characters in your  
"pqrmnoghi" string, you should find that it contains 20 characters instead  
of the 9 you were probably expecting.

So try doing something like
     $string =~ s/\r//g;
after you join it. Or before you join it.

Brian


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

Date: Tue, 10 Aug 2004 18:00:46 GMT
From: "Bill Segraves" <segraves_f13@mindspring.com>
Subject: Re: News::Scan question
Message-Id: <i38Sc.19983$Jp6.17178@newsread3.news.atl.earthlink.net>

"Sandman" <mr@sandman.net> wrote in message
news:mr-9E44F5.23103708082004@individual.net...
> Ok, I've been looking at the News::Scan package, and I can't get my head
around
> it.
<snip>

Surely, you're aware of Google. OTOH, if you were, you would have found
examples of how the author uses New::Scan, e.g.,

http://search.cpan.org/src/GBACON/News-Scan-0.53/eg/

--
Bill Segraves




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

Date: Tue, 10 Aug 2004 18:02:50 GMT
From: "Bill Segraves" <segraves_f13@mindspring.com>
Subject: Re: News::Scan question
Message-Id: <e58Sc.19984$Jp6.9145@newsread3.news.atl.earthlink.net>

"Bill Segraves" <segraves_f13@mindspring.com> wrote in message
news:i38Sc.19983$Jp6.17178@newsread3.news.atl.earthlink.net...
> "Sandman" <mr@sandman.net> wrote in message
> news:mr-9E44F5.23103708082004@individual.net...
<snip>
> Surely, you're aware of Google. OTOH, if you were, you would have found
> examples of how the author uses New::Scan [Oops! News::Scan], e.g.,
>
> http://search.cpan.org/src/GBACON/News-Scan-0.53/eg/
>
 --
Bill Segraves





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

Date: 10 Aug 2004 07:01:28 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: split inconsistency- why?
Message-Id: <776e0325.0408100601.1ab00f10@posting.google.com>

"John W. Krahn" <someone@example.com> wrote in message news:<2kLRc.74830$T_6.55276@edtnps89>...
> Sara wrote:
> > split /,/,'cat,mouse,,eel,fish';
> > 
> > yields
> >   0  'cat'
> >   1  'mouse'
> >   2  ''
> >   3  'eel'
> >   4  'fish'
> > 
> > Fine. Likewise:
> > 
> >    split /,/,',,,cat,,mouse,eel,fish';
> > 
> > yields
> >   0  ''
> >   1  ''
> >   2  ''
> >   3  'cat'
> >   4  ''
> >   5  'mouse'
> >   6  'eel'
> >   7  'fish'
> > 
> > Everybody is happy.  But 
> > 
> >   split /,/,'cat,mouse,eel,fish,,,';
> > 
> > yields 
> >   0  'cat'
> >   1  'mouse'
> >   2  'eel'
> >   3  'fish'
> > 
> > Huh? Where did the trailing items go?
> 
> If you had read the documentation for split you would see that that
> is the defined behavior for zero, one or two argument versions of split.
> 
> perldoc -f split
>         split /PATTERN/,EXPR,LIMIT
>         split /PATTERN/,EXPR
>         split /PATTERN/
>         split   Splits a string into a list of strings and returns that
>                 list.  By default, empty leading fields are preserved,
>                 and empty trailing ones are deleted.
> 
> 
> You will also see that there is a third argument "LIMIT" which will solve
> your problem.
> 
> 
> 
> John

Another incorrect presumption. I did read the documentation. I'm
talking about the choice of the default operation of split.  I'm not
suggesting that it didn't work with additional arguments (which I
predect few if any of my programmers would recognize). I'm suggesting
it was a poor language design choice, and asking what advantage(s)
that choice has for the programmer. An entirely different question.

Sometimes the discussions here are not unlike the fundies argument
against evolution. You miss the whole point, because you believe Perl
is a divine doctrine that can't be questioned. It shouldn't upset you
because someone questions a language design choice.


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

Date: 10 Aug 2004 07:05:30 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: split inconsistency- why?
Message-Id: <776e0325.0408100605.22f69e27@posting.google.com>

Tad McClellan <tadmc@augustmail.com> wrote in message news:<slrnchfano.1ej.tadmc@magna.augustmail.com>...
> Sara <genericax@hotmail.com> wrote:
> > split /,/,'cat,mouse,,eel,fish';
> 
> 
> > Huh? Where did the trailing items go?
> 
> 
> Right where the contract (documentation) says they will go.
> 
> Why are you acting so surprised?
> 
> 
> > I work around this inconsistency by adding in "placeholders" like:
> > 
> >     s/,,/,#,/g; s/,,/,#,/g;
> > 
> > then do the split,then remove the #'s. What a treat. Thanks Larry!
> 
> 
> If you sign a contract without reading it, you deserve any pain
> that you get.
> 
> The corollary then is to read it before you sign it
> (ie. read the docs for a function before you use the function)

Contract huh? With my legal-eagle hat on, a contract requires a
"meeting of the minds". I never agreed to this design choice, so there
is no contract, at least not with me.

I have yet to hear any valid reasons why this was a good design
choice. Just a lot of the usual robotic "read the docs" jabber.  Tell
ya what-

"read the post"


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

Date: Tue, 10 Aug 2004 15:06:48 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: split inconsistency- why?
Message-Id: <x7smavm3rm.fsf@mail.sysarch.com>

>>>>> "S" == Sara  <genericax@hotmail.com> writes:

  S> I have yet to hear any valid reasons why this was a good design
  S> choice. Just a lot of the usual robotic "read the docs" jabber.  Tell
  S> ya what-

learn awk. split's default behavior follows awk's.

and awk was a major influence on perl's design (hashes, -p loop, scalar
range, etc.)

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: Tue, 10 Aug 2004 11:12:09 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: split inconsistency- why?
Message-Id: <slrnchhsup.4b6.tadmc@magna.augustmail.com>

Sara <genericax@hotmail.com> wrote:
> Tad McClellan <tadmc@augustmail.com> wrote in message news:<slrnchfano.1ej.tadmc@magna.augustmail.com>...
>> Sara <genericax@hotmail.com> wrote:
>> > split /,/,'cat,mouse,,eel,fish';
>> 
>> 
>> > Huh? Where did the trailing items go?
>> 
>> 
>> Right where the contract (documentation) says they will go.


> Contract huh? With my legal-eagle hat on, a contract requires a
> "meeting of the minds". 


If you agree to call the function, then there _has_ been a
meeting of the minds.

If you didn't want done what the function does, then you
wouldn't call that function.


> I never agreed to this design choice, 


When you call the function, you are agreeing that it will do what
its docs say it will do.


> so there
> is no contract, at least not with me.
> 
> I have yet to hear any valid reasons why this was a good design
> choice. 


Pass a -1 as a 3rd argument, and that design choice will become moot.


> Just a lot of the usual robotic "read the docs" jabber.  


The docs tell you how to disable the design choice that
you object to. Simply disable it and move on, no biggie.


> Tell
> ya what-
> 
> "read the post"


Tell you what, meet the killfile.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 10 Aug 2004 17:26:47 +0100
From: Peter Hickman <peter@semantico.com>
Subject: Re: split inconsistency- why?
Message-Id: <4118f748$0$13089$afc38c87@news.easynet.co.uk>

Sara wrote:
> Everybody is happy.  But 
> 
>   split /,/,'cat,mouse,eel,fish,,,';
> 
> yields 
>   0  'cat'
>   1  'mouse'
>   2  'eel'
>   3  'fish'
> 
> Huh? Where did the trailing items go?

If you had read the documentation as you have claimed then why are you asking 
where the trailing items went? You would know, are you trolling?

> I work around this inconsistency by adding in "placeholders" like:
> 
>     s/,,/,#,/g; s/,,/,#,/g;
> 
> then do the split,then remove the #'s. What a treat. Thanks Larry!

Larry created Perl just to piss you off.

> But I can't help but wonder- what programming advantage does this
> offer and why was split designed to ignore some split candidates such
> as these trailing items?   And why only omit trailing items, and not
> leading? Was there some presumption made about leading ones being more
> meaningful than trailing? Very odd presumption if so!

Because if you are processing several lines from comma separated file for 
example then trailing blank cells are of no interest but the leading blank cells 
are because they help line up data with the previous line. Gosh that was hard.

> To the programmer, it would be easier to make split consistent, and in
> those cases when the programmer doesn't want empty trailing items he
> can easily prepare the scalar to get rid of them:

If most people require 'keep the leading, lose the trailing' then it would be 
better if this were the default behaviour rather than everyone having to write 
two lines of code where they could write one. Only academics think the 
programmer should be a slave to the language, Larry likes to make the language 
work for the programmer.

By the way you are the first 'programmer' (I give you the benefit of the doubt 
here) that has had issue with the behaviour of split. They rest of us find it 
very useful.

> Perl is pretty much self-consistent, in fact this is one of very few
> cases I've encountered which lacks consistency. I'd be interested
> though in hearing the arguments on why this was a beneficial language
> design choice?

It is realy realy useful. Boy are you going to have fun with OOPerl.


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

Date: 10 Aug 2004 16:34:53 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: split inconsistency- why?
Message-Id: <slrnchhu9d.gb.xx087@smeagol.ncf.ca>

At 2004-08-10 11:06AM, Uri Guttman <uri@stemsystems.com> wrote:
> >>>>> "S" == Sara  <genericax@hotmail.com> writes:
>  
>   S> I have yet to hear any valid reasons why this was a good design
>   S> choice. Just a lot of the usual robotic "read the docs" jabber.  Tell
>   S> ya what-
>  
>  learn awk. split's default behavior follows awk's.

Does it?  a2p begs to differ:

    echo '
        BEGIN {
            s="this,is,a,comma,delimited,string,,"
            split(s,a,/,/)
            for (n in a) {print n ": " a[n]}
            exit
        }
    ' | a2p -
 
produces:
 ...
    $S = 'this,is,a,comma,delimited,string,,';
    @a = split(/,/, $S, 9999);
    foreach $n ($[ .. $#a) {
        print $n . ': ' . $a[$n];
    } 

Not Perl's default split behaviour.


-- 
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca


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

Date: 10 Aug 2004 17:05:31 GMT
From: ctcgag@hotmail.com
Subject: Re: split inconsistency- why?
Message-Id: <20040810130531.059$qR@newsreader.com>

genericax@hotmail.com (Sara) wrote:
> "John W. Krahn" <someone@example.com> wrote in message
> > >
> > > Huh? Where did the trailing items go?
> >
> > If you had read the documentation for split you would see that that
> > is the defined behavior for zero, one or two argument versions of
> > split.
 ...
>
> Another incorrect presumption. I did read the documentation.

Bullshit.  Had you read the documentation, you would not be asking where
the trailing items went, you would know where they went.  Furthermore, you
would have used the proper solution (the limit argument) rather than that
god-aweful hack you included in your first post.

> I'm
> talking about the choice of the default operation of split.

No, you lying through your teeth in an effort to save face.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Tue, 10 Aug 2004 18:21:40 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: split inconsistency- why?
Message-Id: <cfavve$gp2$1@sun3.bham.ac.uk>



ctcgag@hotmail.com wrote:

> genericax@hotmail.com (Sara) wrote:
> 
>>"John W. Krahn" <someone@example.com> wrote in message
>>
>>>>Huh? Where did the trailing items go?
>>>
>>>If you had read the documentation for split you would see that that
>>>is the defined behavior for zero, one or two argument versions of
>>>split.
> 
> ...
> 
>>Another incorrect presumption. I did read the documentation.
> 
> 
> Bullshit.  Had you read the documentation, you would not be asking where
> the trailing items went, you would know where they went.   Furthermore, you
> would have used the proper solution (the limit argument) rather than that
> god-aweful hack you included in your first post.

That's rather irrefutable isn't it?

By all means question the reasoning behind design decision.  I happen to 
agree that the default operation of split is counterintuative and not 
what I'd have chosen.

Do not claim to have read the documentation when you did not know how to 
select the alternate behaviour.

If you make a dumb mistake because you didn't read the documentation 
properly people here will deride you.  Join in, play along, deride 
yourself.  Do not attempt to defend you error or deny that you made the 
mistake.  This will only increase the derision.



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

Date: Tue, 10 Aug 2004 15:26:35 +0200
From: Sandman <mr@sandman.net>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <mr-A5FC22.15263510082004@individual.net>

In article <slrnchgvoa.ec9.abigail@alexandra.abigail.nl>,
 Abigail <abigail@abigail.nl> wrote:

> ;; > What does your question have to do with the statistics 
> ;; > for comp.lang.perl.misc?
> ;;  
> ;;  1. It concerns News::Scan, the modules used to generate the statistics.
> 
> Yes, and?

What kind of answer are you looking for?

> ;;  2. It is directed at Greg, the author of News::Scan, and the author of
> ;;     the statistics.
> 
> That's what email is for.

clp.misc aren't for perl discussions/help any more? I must have missed the memo.

> ;;  Maybe he has an automatic newsmailer for these statistics and no longer 
> ;;  read the group, though.
> 
> Nah, he types in the statistics entirely by hand. It takes him a week to
> do it, and that's why he can't answer any other questions.

You don't seem to have a point with your post - why did you post it? To get 
attention? To make yourself look less intelligent? Perhaps you recently made a 
genius post and want some balance to not raise the expectations of other in the 
group? If so - good job, expectations are as low as they could get!

-- 
Sandman[.net]


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

Date: Tue, 10 Aug 2004 07:45:37 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <slrnchhgrh.3tt.tadmc@magna.augustmail.com>

Sandman <mr@sandman.net> wrote:
> In article <slrnchfovc.1qj.tadmc@magna.augustmail.com>,
>  Tad McClellan <tadmc@augustmail.com> wrote:
> 
>> Sandman <mr@sandman.net> wrote:
>> > In article <10hev88pvh1to9b@corp.supernews.com>,
>> >  Greg Bacon <gbacon@hiwaay.net> wrote:
>> > 
>> >> Following is a summary of articles spanning a 7 day period,
>> 
>> > I posted a question about News::Scan in an earlier post.
>> 
>> 
>> What does your question have to do with the statistics 
>> for comp.lang.perl.misc?
> 
> 1. It concerns News::Scan,


Then the Subject header should say something about News::Scan.

Please help us keep threads threaded, don't put things unrelated
to the Subject into the thread.


> 2. It is directed at Greg, 


It was directed to thousands of people around the world.

If it was directed at Greg it would have been an email message
rather than an Usenet message.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 10 Aug 2004 16:23:22 +0200
From: Sandman <mr@sandman.net>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <mr-B99E2E.16232210082004@individual.net>

In article <slrnchhgrh.3tt.tadmc@magna.augustmail.com>, Tad McClellan
<tadmc@augustmail.com> wrote:

>>>>> Following is a summary of articles spanning a 7 day period,
>>>> 
>>>> I posted a question about News::Scan in an earlier post.
>>> 
>>> What does your question have to do with the statistics for
>>> comp.lang.perl.misc?
>> 
>> 1. It concerns News::Scan,
> 
> Then the Subject header should say something about News::Scan.

My original post, the one I wanted Greg to view, did exactly that.

> Please help us keep threads threaded, don't put things unrelated to
> the Subject into the thread.

I replied to a post, I didn't create the thread. My reply was directed to a 
specific poster.

>> 2. It is directed at Greg,
> 
> It was directed to thousands of people around the world.

No, it was received by thousands of people, but directed at Greg.

> If it was directed at Greg it would have been an email message rather
> than an Usenet message.

Illogical. Are you saying your post wasn't directed at me? You directed it 
towards thousands of people around the world? That doesn't make much sense, 
does it?

-- 
Sandman[.net]


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

Date: Tue, 10 Aug 2004 14:50:32 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <Yg5Sc.39$EQ5.37@nwrddc03.gnilink.net>

Sandman wrote:
> In article <slrnchhgrh.3tt.tadmc@magna.augustmail.com>, Tad McClellan
> <tadmc@augustmail.com> wrote:
>> Then the Subject header should say something about News::Scan.
>
> My original post, the one I wanted Greg to view, did exactly that.

It did not. And it still says "Statistics for comp.lang.perl.misc" and
nothing about News::Scan.

>> Please help us keep threads threaded, don't put things unrelated to
>> the Subject into the thread.
>
> I replied to a post, I didn't create the thread.

You replied with a request that had nothing to do with the statistics for
comp.lang.perl.misc.

> My reply was
> directed to a specific poster.

Then why did you send it to thousands of people instead of to him?

*PLONK*

jue




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

Date: Tue, 10 Aug 2004 11:18:59 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <slrnchhtbj.4b6.tadmc@magna.augustmail.com>

Sandman <mr@sandman.net> wrote:
> In article <slrnchgvoa.ec9.abigail@alexandra.abigail.nl>,
>  Abigail <abigail@abigail.nl> wrote:
> 
>> ;; > What does your question have to do with the statistics 
>> ;; > for comp.lang.perl.misc?
>> ;;  
>> ;;  1. It concerns News::Scan, the modules used to generate the statistics.
>> 
>> Yes, and?
> 
> What kind of answer are you looking for?


The subject of a post is kinda expected to align with the Subject of
the post.

Yours didn't.

We are trying to see how they might be connected.

We are looking for an answer that explains how your post was
about Statistics for comp.lang.perl.misc.


>> ;;  2. It is directed at Greg, the author of News::Scan, and the author of
>> ;;     the statistics.
>> 
>> That's what email is for.
> 
> clp.misc aren't for perl discussions/help any more?


News groups are, well, *groups*. Greg is not a group, though he
may be a member of the group.

Putting "Greg" at the beginning of your post does not "direct" it
to Greg.

Posting to a newsgroup directs it to the group.

Email can be used to direct a message to a particular individual.


> You don't seem to have a point with your post - 


You didn't follow netiquette (where the Subject reflects the actual subject).


> why did you post it?


On the off chance that you would like to avoid appearing rude 
in the future perhaps?


> To make yourself look less intelligent?


So long fool.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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