[28432] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9796 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 3 11:06:07 2006

Date: Tue, 3 Oct 2006 08:05:07 -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, 3 Oct 2006     Volume: 10 Number: 9796

Today's topics:
    Re: ANN:Just released "The Webmaster Collection" <tadmc@augustmail.com>
    Re: get rid of ^M <bik.mido@tiscalinet.it>
    Re: Help with Code <rvtol+news@isolution.nl>
    Re: Help with Code <mritty@gmail.com>
    Re: How to delete temporary file after displaying in br <ynl@nsparks.net>
    Re: How to delete temporary file after displaying in br <bart@nijlen.com>
    Re: How to delete temporary file after displaying in br <bik.mido@tiscalinet.it>
        Kolmogorov-Smirnov test <Wuming.Gong@gmail.com>
        Kolmogorov-Smirnov test <Wuming.Gong@gmail.com>
    Re: list vs. array <bik.mido@tiscalinet.it>
    Re: My first socket question <bik.mido@tiscalinet.it>
    Re: my vs our for class data anno4000@radom.zrz.tu-berlin.de
    Re: my vs our for class data <someone@example.com>
    Re: my vs our for class data <rmoritz@quantm.invalid.co.za>
    Re: my vs our for class data <rmoritz@quantm.invalid.co.za>
        problems with regex matching - invalid ranges, quantifi <jack_posemsky@yahoo.com>
    Re: problems with regex matching - invalid ranges, quan <mritty@gmail.com>
        this is annoying <MisterPerl@gmail.com>
    Re: this is annoying <mritty@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 3 Oct 2006 07:56:59 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: ANN:Just released "The Webmaster Collection"
Message-Id: <slrnei4ngr.tiv.tadmc@magna.augustmail.com>

jfmoreno@gitanosoftware.com <jfmoreno@gitanosoftware.com> wrote:


> To preview and purchase


Commercial advertisements are not welcome in Usenet discussion newsgroups.


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


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

Date: 3 Oct 2006 12:08:49 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: get rid of ^M
Message-Id: <9kd4i21sqii9t1mebth5k0258dbbvcm4ou@4ax.com>

On Mon, 02 Oct 2006 12:17:50 -0700, hmchkus <> wrote:

>How to get rid of the "^M" in my perl script?
>
>I know I can run "dos2unix" command in Solaris, but can I settle this
>in windows before I copy over the file? No need to open the file in
>windows.   Thanks!

  C:\temp>cat foo.pl
  #!/usr/bin/perl -l
  
  use strict;
  use warnings;
  use PerlIO;
  
  open my $fh1, '>', "foo1" or die $!;
  print for "open mode: '>'",
    PerlIO::get_layers $fh1;
  
  open my $fh2, '>:pop', "foo2" or die $!;
  print for "open mode: '>:pop'",
    PerlIO::get_layers $fh2;
  
  __END__
  
  C:\temp>foo
  open mode: '>'
  unix
  crlf
  open mode: '>:pop'
  unix


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Tue, 3 Oct 2006 13:58:09 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Help with Code
Message-Id: <eftqbq.16o.1@news.isolution.nl>

Ian Wilson schreef:

> \d matches "0", "1" ... "8" or "9"

Last time I checked, \d matched 268 different characters. Dear
programmer, if you mean [0-9], then write [0-9].

-- 
Affijn, Ruud

"Gewoon is een tijger."




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

Date: 3 Oct 2006 05:12:12 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Help with Code
Message-Id: <1159877532.845010.299090@i42g2000cwa.googlegroups.com>

Dr.Ruud wrote:
> Ian Wilson schreef:
>
> > \d matches "0", "1" ... "8" or "9"
>
> Last time I checked, \d matched 268 different characters. Dear
> programmer, if you mean [0-9], then write [0-9].

Er.  Huh?   I realize that \w will match not only 'a'..'z', 'A'..'Z',
'0'..'9', and _, and that all the "international" letters such as =E1
and =D1 are included as well, depending on locale.  But other than the
ten characters Ian implied, what else does \d match?

I did take a look at `perldoc perlreref`, which in turn referred me to
`perldoc perllocale`, but I confess that I don't get it - I'm extremely
na=EFve when it comes to locales...

Paul Lalli



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

Date: Tue, 3 Oct 2006 13:25:33 +0200
From: Yohan N Leder <ynl@nsparks.net>
Subject: Re: How to delete temporary file after displaying in browser ?
Message-Id: <MPG.1f8c6713d8d20be19898d9@news.tiscali.fr>

In article <1159866878.669706.187600@e3g2000cwe.googlegroups.com>, 
bart@nijlen.com says...
> As a general principle, I meant something like this:
> 
>   #!/usr/bin/perl
>   print "Content-Type: image/gif\n\n";
>   use strict;
>   use warnings;
>   my $file = 'image.gif';
>   my $gif;
>   open my $F, '<', $file || die "Cant open $file: $!";
>   $gif.=$_ while(<$F>);
>   close $F || die "Cant close $file: $!";
>   unlink $file; # safe to unlink here
> 

So, if I well understand, I could print out something like this in my 
main CGI script :

my imgb64 = ... here the base64 encoding of the temp image file
my $imghtm = "<img src='"/cgi-bin/getimg.cgi?$imgbase64."' border=0 
width=150 height=150>";
print "<html><head></head><body>".$imghtm."</body></html>";
unlink $imgpath;
exit 0;

with getimg.cgi processing to print the base64 content toward the 
browser : right ?

> You're right that unlink is not good in your code. I would probably use
> a cronjob to delete temporary files older than X.
> 

Yes, I known it also a possibility, but the reason why I'm trying to 
work around this is that this script will be used on several servers, 
some being hosted by a third party company and it implies to add some 
more documentation about script shell editing, about cronjob scheduling 
and in the worst case something saying webmaster has to contact the 
admin. Well, even if it's a lot easier, if I could do the job from 
within my CGI script(s) it would be better for future install.


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

Date: 3 Oct 2006 06:18:30 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: How to delete temporary file after displaying in browser ?
Message-Id: <1159881510.761411.243360@e3g2000cwe.googlegroups.com>

Yohan N Leder wrote:

> [...]
> So, if I well understand, I could print out something like this in my
> main CGI script :
>
> my imgb64 = ... here the base64 encoding of the temp image file
> my $imghtm = "<img src='"/cgi-bin/getimg.cgi?$imgbase64."' border=0
> width=150 height=150>";
> print "<html><head></head><body>".$imghtm."</body></html>";
> unlink $imgpath;
> exit 0;
>
> with getimg.cgi processing to print the base64 content toward the
> browser : right ?

URLs have length limitations both at server side and at client side
(IIRC I think MSIE allows up to 2048 characters). You could use POST in
stead of GET to work around this:

  <form method="post" action="/cgi-bin/getimg.cgi">
  <input type="hidden" name="imgbase64" value="$imgbase64">
  <input type="submit" value="View image">
  </form>

Or use a frame/iframe to display the image and automatically submit the
form.

Or you could use GET with another encryption algorithm that guarantees
a URL that is short enough.

Or let the main program sleep for 30 seconds or so and then perform the
unlink before quitting. 

Plenty of choice :-)

-- 
 Bart



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

Date: 3 Oct 2006 15:31:50 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How to delete temporary file after displaying in browser ?
Message-Id: <nuo4i21a1b2bqogc337ifem3ng68c6hsbm@4ax.com>

On Tue, 3 Oct 2006 04:48:47 +0200, Yohan N Leder <ynl@nsparks.net>
wrote:

>> I'm not really sure if I understand. It seems that you create a
>> temporary but *static* file to be served directly by the browser. Why
>> don't you serve it dinamically instead?
>
>The file I have to display, then delete has been previously uploaded 
>from client to server. After this upload stage (done), I have to do 
>something like this (shorten at its maximum) :

What I meant was something along the lines of the minimal example
suggested by Bart Van der Donck in
<news:1159866878.669706.187600@e3g2000cwe.googlegroups.com>.

>#!/usr/bin/perl
>use CGI::Carp qw/fatalsToBrowser/;

As a side note, you know that this will have to go away in
"production", don't you?

>use strict;
>use warnings;
>$|=1;
>print "Content-type: text/html; charset=iso-8859-1\n\n";
>my $imgpath = "../httpdocs/upload/tmp.gif";
>my $imgurl = "/upload/tmp.gif";
>my $imghtm = "<img src='".$imgurl."' border=0 width=150 height=150>";

".$imgurl." ?
         ^
         ^

>print "<html><head></head><body>".$imghtm."</body></html>";
>#... now I need to unlink this $imgpath ...
>exit 0;
>
>So, how to achive the commented step ? Can I just unlink after printing 

You don't print() the image, but its url which will make the browser
issue another request. If you unlink() the image at this point it may
not be available when the request is done.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 3 Oct 2006 05:53:45 -0700
From: "Wuming.Gong@gmail.com" <Wuming.Gong@gmail.com>
Subject: Kolmogorov-Smirnov test
Message-Id: <1159880025.824917.98610@e3g2000cwe.googlegroups.com>

Dear list,

Is there any perl modules for conducting Kolmogorov-Smirnov test
(http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test)?

Thanks,

WUming



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

Date: 3 Oct 2006 05:53:54 -0700
From: "Wuming.Gong@gmail.com" <Wuming.Gong@gmail.com>
Subject: Kolmogorov-Smirnov test
Message-Id: <1159880034.311520.99230@e3g2000cwe.googlegroups.com>

Dear list,

Is there any perl modules for conducting Kolmogorov-Smirnov test
(http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test)?

Thanks,

Wuming



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

Date: 3 Oct 2006 13:57:04 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: list vs. array
Message-Id: <ohj4i214084c35iqoh3q50l98hga66qaj9@4ax.com>

On 2 Oct 2006 14:14:17 -0700, "robb@acm.org" <robb@acm.org> wrote:

>> >I seem to remember this, and so long ago I adopted a coding style of
>> >only passing scalars - actual scalars and refs - in my functions.
>>
>> Quite limitative and inefficiency-prone. But if you're feeling fine
>> with it...
>
>For sure, it's good maintenance-efficiency-wise.  In what ways would it
>be ineffiicient?

You do to undo. If you do this, you add an intermediate step which
does take time, and I'm certainly not a
premature-optimization-kinda-guy, but it strikes me as inefficient and
inelegant to add unnecessary intermediate steps. Also, in $Larry's
words Perl is a postmodern language: it's multiparadigmatic and it's
officially ok to program only in a suitable subset of it. But not
making use of its full expressive power is always to loose something.
It's officially ok to speak only a subset of a language as you learn
it. But as soon one gets more acquainted with it, it's natural to want
to make use of its full expressive power, i.e. to choose the "right"
tool for each given situation instead of sticking to one particular
tool that was easy to understand and take care of when you were still
a newbie. Please note that I'm *not* advocating golf/obfu-like
programming in production code: just the "right" tool for the right
situation.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 3 Oct 2006 14:03:33 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: My first socket question
Message-Id: <90k4i2pq1m52lhs72n6pcukc9f3f6sbovs@4ax.com>

On Mon, 02 Oct 2006 10:02:07 -0700, Jim Gibson
<jgibson@mail.arc.nasa.gov> wrote:

>> >>   while (1) {
>> >>       $cnt++;
>> >>       $val=rand;  # these are the important calculations!!
>> >>       next unless $sel->can_read(0.2);
>> >
>> >Why the 0.2?  If the main task is $cnt++ and $val=rand, then it should
>> >be spending most of it's time there and not waiting for someone to make
>> >a connection that quite likely will not come within any given 0.2 anyway.
>
>The benefit of using a timeout to can_read to control program execution
>and timing is better responsiveness. If you use sleep (or select) to
>pause the program when it has nothing to do but wait for clients, you
>cannot respond to the client until the timeout to sleep has expired. If
>you use a timeout parameter for can_read, you can respond immediately.
>After the client has been serviced, the program can decide to perform
>some calculations or call can_read again, perhaps with a shorter
>timeout this time.

So, all in all, is it better to time out or not? IIUC your answer is
affirmative, whereas xhoster's one is negative. Since you both are
much more knowledgeable than I am... I'm quite lost. (Although I must
say that what I got thus far is fine for me now, but I want to learn
more for the future.)

>> "registered" handles. But I'm not really sure if I know what that
>> means. No, I'm sure: I *don't* know.
>
>"registered" means that IO::Select::add has been called on the
>IO::Select object with the handle for the socket. Read up on Unix's
>select statement. IO::Select is a Perl mapping to that routine, which

I'll do.

>> BTW: the "real" application is not that computation intensive, and
>> actually has a sleep(1) in the main cycle. I get your point, though.
>> And I thank you for your informative reply.
>
>That is a common situation. It is rare for a program that needs to
>service clients to be CPU-bound. Thus, some sort of sleep or timeout is

Indeed, but in this case which is probably the uncommon one, the
application's main purpose is other than servicing clients: the latter
is an add-on aimed at providing further functionality. So a priori it
may also have been CPU-bound...

>usually inserted. Using the timeout of select is a good method of
>sleeping while remaining responsive.

So, again, all in all you recommend doing so, don't you? Are there two
schools of thought in this respect?


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 3 Oct 2006 10:32:11 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: my vs our for class data
Message-Id: <4oeshbFdv6faU1@news.dfncis.de>

Ralph Moritz  <rmoritz@quantm.invalid.co.za> wrote in comp.lang.perl.misc:
> Hi,
> 
> I know this probably belongs in perl.beginners, but my ISP doesn't
> carry that group :( . Please could someone what the difference is
> between
> 
> { package Foo;
>   my $data;
> }
> 
> and
> 
> { package Foo;
>   our $data;
> }
> 
> Is it okay to use our for "class data"?

Define "okay".  Both will work.

In a strict OO setting class data will be accessed exclusively through
accessor methods.  Using lexical variables guarantees that accessors
can't be bypassed by code outside your class definition.  Package
variables can be accessed directly, so there is a way to break
encapsulation.

The answer is the usual:  Use lexicals unless you need the properties
of package variables.  If you are doing strict OO you don't need them.

> The reason I'm asking is
> that I'm eval'ing a Perl script to obtain the value of $data.

I'm not sure what that means, but if it involves accessing the package
variables directly you're breaking encapsulation.

Anno


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

Date: Tue, 03 Oct 2006 10:57:28 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: my vs our for class data
Message-Id: <smrUg.38591$Lb5.20422@edtnps89>

Ralph Moritz wrote:
> 
> I know this probably belongs in perl.beginners, but my ISP doesn't
> carry that group :( .

perl.beginners is a mailing list so you are saying that your ISP doesn't allow
you to send or receive email?


John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


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

Date: Tue, 03 Oct 2006 12:39:19 +0100
From: Ralph Moritz <rmoritz@quantm.invalid.co.za>
Subject: Re: my vs our for class data
Message-Id: <uk63hy6fs.fsf@quantm.invalid.co.za>

"John W. Krahn" <someone@example.com> writes:

> Ralph Moritz wrote:
>> 
>> I know this probably belongs in perl.beginners, but my ISP doesn't
>> carry that group :( .
>
> perl.beginners is a mailing list so you are saying that your ISP doesn't allow
> you to send or receive email?

Ah, that would explain it. Funny that I can access it through
nntp.aioe.org though.

-- 
Ralph Moritz
Quantum Solutions       Ph: +27 315 629 557
GPG Public Key: http://ralphm.info/public.gpg


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

Date: Tue, 03 Oct 2006 12:52:10 +0100
From: Ralph Moritz <rmoritz@quantm.invalid.co.za>
Subject: Re: my vs our for class data
Message-Id: <ufye5y5ud.fsf@quantm.invalid.co.za>

anno4000@radom.zrz.tu-berlin.de writes:

> Ralph Moritz  <rmoritz@quantm.invalid.co.za> wrote in comp.lang.perl.misc:
[snip]
>> The reason I'm asking is
>> that I'm eval'ing a Perl script to obtain the value of $data.
>
> I'm not sure what that means, but if it involves accessing the package
> variables directly you're breaking encapsulation.

Sorry if this wasn't well explained. Say I'm getting the value of
$data by eval'ing a file, using the eval_file() sub defined below:

{ package Foo;
  our $data;

  sub eval_file {
    my $file = shift;
    open(my $fh, $file);
    my $code = join('', <$fh>);
    eval $code or die $@;
  }
}

It seems I have to declare $data as a package variable (if I want to
use it as a class variable). Or is there a better way?

-- 
Ralph Moritz
Quantum Solutions       Ph: +27 315 629 557
GPG Public Key: http://ralphm.info/public.gpg


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

Date: 3 Oct 2006 07:33:08 -0700
From: "Jack" <jack_posemsky@yahoo.com>
Subject: problems with regex matching - invalid ranges, quantifier follows nothing, etc.
Message-Id: <1159885988.140308.154140@i42g2000cwa.googlegroups.com>

Hi folks,

I want to be able to test any string (yes any string with any
combination of -, 0-9, +, -, [, and other non alphanumeric characters)
against a set of target strings (and with these also, anything goes in
these strings as well)..Here is an example of the code which as you can
see pattern matches:
while (<SOURCE2>) {
@temparray2 = split(/$delimiter/, $_);
for ($i=0;$i<=$#target;$i++)
	{
    if ($target[$i] =~ m/$temparray2[0]/i) {  print " match "; }
        }
} #end while

This works great and runs through the file matching each $temparray2[0]
element against a target set of elements in an array, until I run into
some character that Regex complains about.  What do I need to do with
my code to allow the flexibility I am looking for, the ability to case
insensitively match many, many patterns I have against other complex
strings without the complaints ; do I need to preprocess $temparray2[0]
to remove non alphanumeric characters and if so, whats is the code to
strip these out - here is a example data where regex complains about
$temparray2[0]:
METHYLENETETRAHYDROFOLATE DEHYDROGENASE/METHENYLTETRAHYDROFOLATE
CYCLOHYDROLASE/FORMYLTETRAHYDROFOLATESYNTHETASE,
NADP(+)-DEPENDENTMETHYLTETRAHYDROFOLATE CYCLOHYDROLASE DEFICIENCY,
INCLUDED

Here are some example errors:

Invalid [] range "y-4" in regex; marked by <-- HERE in
m/1-naphthacenecarboxylic
 acid, 2-ethyl-1,2,3,4,6,11-hexahydro-2,5,
7-trihydroxy-6,11-dioxo-4-[[2,3,6-tri
deoxy-4 <-- HERE
-O-[2,6-dideoxy-4-O-((2R-trans)-tetrahydro-6-methyl-5-oxo-2H-py
ran-2-yl)
-.alpha.-L-lyxo-hexopyranosyl]-3-(dimethylamino)-.alpha.-L-lyxo-hexopy
ranosyl]oxy]-, methyl ester,(1R-(1.alpha.,2.beta.,4.beta.))-(9CI)/ at
 ...

Quantifier follows nothing in regex; marked by <-- HERE in
m/METHYLENETETRAHYDRO
FOLATE DEHYDROGENASE/METHENYLTETRAHYDROFOLATE
CYCLOHYDROLASE/FORMYLTETRAHYDROFOL
ATESYNTHETASE, NADP(+ <-- HERE )-DEPENDENTMETHYLTETRAHYDROFOLATE
CYCLOHYDROLASE
DEFICIENCY, INCLUDED/ at ...



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

Date: 3 Oct 2006 07:40:56 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: problems with regex matching - invalid ranges, quantifier follows nothing, etc.
Message-Id: <1159886456.130365.13980@m73g2000cwd.googlegroups.com>

Jack wrote:
> I want to be able to test any string (yes any string with any
> combination of -, 0-9, +, -, [, and other non alphanumeric characters)
> against a set of target strings (and with these also, anything goes in
> these strings as well).

perldoc -f quotemeta
perldoc perlreref (search for \Q and \E)

$pattern = "+ foo [0-a]";
if ($string =~ /\Q$pattern\E/) {
  print "$string contained $pattern\n";
}

Paul Lalli



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

Date: 3 Oct 2006 06:24:55 -0700
From: "Mr P" <MisterPerl@gmail.com>
Subject: this is annoying
Message-Id: <1159881895.514987.307340@b28g2000cwb.googlegroups.com>

  shift split /\s+/, @$tx;

Type of arg 1 to shift must be array (not split) at
/production/fe/users/feot/acs/ACS_Spex.pm line 5, near "$tx )"

  shift ( split /\s+/, @$tx );
(same error)

It doesn't make sense that I can do:

  @array = arrayOp args

but I can't do

   @array = arrayOp1 (arrayOp2 args)


   **********************************************

Larry you almost always make things work as expected, but for
perlfunction "chains" like

  op1 op2 op3 ... opn arg

everything is almost always busted. This is "the stuff" of clean,
concise syntax (chains) and they don't often work in Perl.

  scalarOp (stuff)
should always try its best to turn "stuff" into a scalar
(precedence-rules followed of course)

Likewise,
  arrayOp (stuff)

should always try its best to turn "stuff" into an array, coercing
lists if necessary

and of course likewise for hashes

This is particularly true when using parens around stuff- can't make it
much clearer than that to the parser!

Larry I've heard you say personally that your intended design on Perl
was that "things would always always work as you'd expect". That's true
for almost every simple case like

  operator args

and not true for almost every compound case.

Get your knives out Uri et al, but this is annoying, depsite your
defense that Perl design is "always right", and comp scientsts opposing
views are "always wrong". (I've read myriad responses to that effect).


I'll do it in individual lines, whatever..

Rant --



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

Date: 3 Oct 2006 06:48:08 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: this is annoying
Message-Id: <1159883288.797536.96700@e3g2000cwe.googlegroups.com>

Mr P wrote:
> shift split /\s+/, @$tx;
>
> Type of arg 1 to shift must be array (not split) at
> /production/fe/users/feot/acs/ACS_Spex.pm line 5, near "$tx )"
>
>   shift ( split /\s+/, @$tx );
> (same error)

Ignoring for a moment your case that shift should be able to work on
lists, I don't have any idea what you think that should be doing.
split takes an expression and returns a list.  You're giving it an
array.  What is it supposed to be splitting?

> It doesn't make sense that I can do:
>
>   @array = arrayOp args
>
> but I can't do
>
>    @array = arrayOp1 (arrayOp2 args)

It makes perfect sense, actually.  You seem to either not understand or
not like that shift does two separate things.  It both returns the
first argument of the array *AND MODIFIES THAT ARRAY*.  It is not
possible to modify a list.  That's one of the key differences between a
list and an array.  Please see: perldoc -q difference

Now, if you want to make the case that shift() should be able to detect
whether its argument is an array or a list, and not do this second
feature of modification if it's just a list, that's fine.  You'll
probably even get a lot of agreement there.   But to say that it
"doesn't make sense" for shift() to work the way it does is just
pointless.

Have you considered trying to write a wrapper subroutine that will do
what you want?  If passed an array (or possibly necessarily an array
reference?), remove and return the first element, but if passed a list,
just return the first element.

> Get your knives out Uri et al, but this is annoying, depsite your
> defense that Perl design is "always right", and comp scientsts opposing
> views are "always wrong". (I've read myriad responses to that effect).

Now what the hell is the point of this?  Are you looking for solutions,
to improve Perl and the experience of Perl programmers?  Or are you
just looking to whine bitch moan complain and insult?

Paul Lalli



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

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


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