[24194] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6386 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 11 14:05:34 2004

Date: Sun, 11 Apr 2004 11:05:06 -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           Sun, 11 Apr 2004     Volume: 10 Number: 6386

Today's topics:
    Re: [VERY OT] a linguistic question (.sig-related, xpos <bik.mido@tiscalinet.it>
    Re: file access trouble <invalid-email@rochester.rr.com>
        format, stdout, with 'swrite' no hot ^ (woof)
    Re: format, stdout, with 'swrite' no hot ^ <invalid-email@rochester.rr.com>
    Re: new bbs <tadmc@augustmail.com>
    Re: Random Qs: overloading ==; import (Anno Siegel)
    Re: Regexp guestion <ppagee@yahoo.com>
    Re: Returning multiple values <pinyaj@rpi.edu>
        strict irony <jkrugman@yahbitoo.com>
    Re: strict irony <matthew.garrish@sympatico.ca>
    Re: strict irony (Jay Tilton)
    Re: strict irony <jkrugman@yahbitoo.com>
    Re: strict irony <pinyaj@rpi.edu>
    Re: strict irony <matthew.garrish@sympatico.ca>
    Re: strict irony <pinyaj@rpi.edu>
        Where To Go For Classroom Training in CGI? <gcatlin@ix.netcom.com>
    Re: Why are arrays and hashes this way? <jurgenex@hotmail.com>
    Re: Why are arrays and hashes this way? <bik.mido@tiscalinet.it>
    Re: Why are arrays and hashes this way? <pkent77tea@yahoo.com.tea>
    Re: Why are arrays and hashes this way? <pkent77tea@yahoo.com.tea>
    Re: Win32::OLE / WMEncoderAgent issue <pkent77tea@yahoo.com.tea>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 11 Apr 2004 15:48:06 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: [VERY OT] a linguistic question (.sig-related, xposted)
Message-Id: <g3ji709734di1eenl4eqq4pq4u0054jj36@4ax.com>

On 10 Apr 2004 13:06:43 -0700, jl_post@hotmail.com (J. Romano) wrote:

>   How would I say, "I write programs in Perl"?  Do any of the
>following choices sound right?  If not, how would you say it?
>
>      "Scrivo programmi in Perl."
>      "Scrivo programmi con Perl."
>      "Scrivo dei programmi usando Perl."

The second one sounds definitely clumsy, nay, I'd say it's not
correct: it seems you're writing programs *with* someone called Perl.

The third one is technically mostly[*] correct, but I can't imagine
anyone using it in any regular conversation.

I'd go with the first one if it were me, possibly even in a shorter
form: "Programmo in Perl", punto!

>   And how would I say, "I will write in Perl in May"?  Would any of
>these be accurate?
>
>      "Scrivero' un programma in Perl in maggio."

Why not? Well, what about "A Maggio scrivero' un programma in Perl"?

>      "Scrivo in Perl a maggio."

I would tend to consider this an anglicism and definitely it doesn't
sound very good...

>      "Quando viene il maggio, scrivero' Perl."

Huh! Don't!!

>   And can "Perl" be used as a verb?  For example, does the phrase
>"Happy Perling!" have a translation?  My best guess would be:

It is definitely common in the english-based CS slang, see e.g. the
jargon file (=> google!), but not just in the same ways in the
italian-based one and I guess also in other localized ones...

>      "Perlisci con felicita'!"
>or maybe:
>      "Perla felicemente!"

I feel like strongly discouraging you from using constructions like
these, that would be incomprehensible to mostly everyone and
ridiculous to those who could understand what you mean!

The best I can come up with is "Felice Perlaggio!", which doesn't
actually imply a verb. But then I'm not *much* familiar with all CS
italian subcultures, especially as far as Perl is concerned.

OTOH, even in English I've often seen "Happy TeXing!", but if memory
serves, never "Happy Perling!".

>   And, finally, can "Perl" be used as an adjective (like "perlish" in
>English)?.  Would the translation of "This program seems a bit
>perlish" be "Questo programma mi sembra un po' perluto"?

"Perlistico"?

However the same cmts as above apply! As a side note and on an
unrelated basis, in (semi-)private communications I have used the
internationalese puns 'Perl-jutsu' and 'Perl-do'[**]: what about
these, anyway?

>   I know you probably weren't expecting these questions, Michele, but
>I'm asking them to you because I always have a hard time saying to
>Italians that I program in Perl (they seem to understand what I mean,
>but I never kow what's correct).  As you know, prepositions like "to",
>"at", "with", "in", and "on" are difficult to use correctly in another
>language, so I'm hoping you can help me out here.

Well, it's not clear to me at all if you do speak italian or wether
you only have a very limited knowledge in this sense, but in case you
do, then I think it would be sensible to post your question to italian
ng, like it.comp.lang.perl for example... I have not set Followup-To
there because I think it wouldn't have been polite.


[*] But not completely IMO, because it seems that you're *writing* the
programs with the aid (or by means) of a tool called Perl.

[**] To refer to Perl techniques, and to Perl overall philosophy.


HTH,
Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: Sun, 11 Apr 2004 13:36:09 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: file access trouble
Message-Id: <40794924.6020701@rochester.rr.com>

Chuck wrote:

> Bob,
> 
> Tried your suggestion - did not make any difference - my script does not
> create the NEW file. Using ActiveState latest version.
> 
> 

Well, here is the exact source I ran (verbatim with yours except for the 
file names and better die messages), along with the exact output:

D:\junk>type junk444.pl
use strict;
use warnings;

my $text1;
my $text2;

my $OldFile = "d:/junk/junk444.txt";
my $NewFile = "d:/junk/junk444a.txt";

open(OLD, '<', $OldFile) or die "Oops, couldn't open $OldFile, $!";
open(NEW, '>', $NewFile) or die "Oops, couldn't open $NewFile, $!";

while (<OLD>) {
   $text1 = substr($_,0,5);
   $text2 = crypt(substr($_,5,8),substr($_,13,2));
   print NEW "$text1 $text2 /n";
}

close OLD or die "$!\n";
close NEW or die "$!\n";
rename($NewFile,$OldFile) or die "$!\n";

D:\junk>type junk444.txt
asdflkjsdflkjsdflksdflkjsdflkj
weroiuwqeroiuweroiwueroiuwerqweoiu
xcvzxcvmnzxcvxzcvxzcvzxcmbnxczvmnbw

D:\junk>perl junk444.pl

D:\junk>type junk444.txt
asdfl sdT3lI5wcQc1Y /nweroi weI0TeB.6rg/o /nxcvzx xzOM.vGz4CsCs /n
D:\junk>ver

Windows 98 [Version 4.10.2222]


D:\junk>perl -v

This is perl, v5.8.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2002, Larry Wall

Binary build 806 provided by ActiveState Corp. http://www.ActiveState.com
Built 00:45:44 Mar 31 2003


Perl may be copied only under the terms of either the Artistic License 
or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.


D:\junk>

The junk444a.txt file does not appear, since it was renamed over top of 
the original junk444.txt file, which is now gone.

HTH.
-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: 11 Apr 2004 08:33:36 -0700
From: drubnone@yahoo.com (woof)
Subject: format, stdout, with 'swrite' no hot ^
Message-Id: <7b21a826.0404110733.c877b0f@posting.google.com>

Monkey'd right out of perlform, I 'print' a format string to
to a variable with swrite like so:


$FO_UP = ' @<<<<<<<<<<<<<                    | ^<<<<<<<<<<<<<<<<<<<<<<<<<';
$name = 'John Doe';
$note = 'this is a very long note some would say for a 25ish space';
$psec .= swrite(<<"END", $name, $note);

sub
swrite {
  my $format = shift;
  $^A = "";
  formline($format, @_);
  return $^A;
}

Isn't the second format string "^<<<<<<<<" supposed to produce 
multiline output?


I expect something like this:

 John Doe                     this is a very long
                              note some would say
                              for .....

I get this:

 John Doe                     this is a very long

Am I right or wrong?  Should I expect the first or second output?

Thanks


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

Date: Sun, 11 Apr 2004 17:42:15 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: format, stdout, with 'swrite' no hot ^
Message-Id: <407982BD.3080305@rochester.rr.com>

woof wrote:

> Monkey'd right out of perlform, I 'print' a format string to
> to a variable with swrite like so:
> 
> 
> $FO_UP = ' @<<<<<<<<<<<<<                    | ^<<<<<<<<<<<<<<<<<<<<<<<<<';
> $name = 'John Doe';
> $note = 'this is a very long note some would say for a 25ish space';
> $psec .= swrite(<<"END", $name, $note);
> 
> sub
> swrite {
>   my $format = shift;
>   $^A = "";
>   formline($format, @_);
>   return $^A;
> }
> 
> Isn't the second format string "^<<<<<<<<" supposed to produce 
> multiline output?
> 
> 
> I expect something like this:
> 
>  John Doe                     this is a very long
>                               note some would say
>                               for .....
> 
> I get this:
> 
>  John Doe                     this is a very long
> 
> Am I right or wrong?  Should I expect the first or second output?
> 
> Thanks
> 

That doesn't compile as posted.  *Please* copy/paste working code.

If you look at:

     perldoc -f formline

you will see where it says "You may therefore need to use
multiple formlines to implement a single record format, just
like the format compiler.".  Some more calls of formline might give you 
what you want, although you may need to alter the format and supplied 
variables for those subsequent calls.

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Sun, 11 Apr 2004 13:24:24 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: new bbs
Message-Id: <slrnc7j3ao.stt.tadmc@magna.augustmail.com>

Robin <robin@infusedlight.net> wrote:

> From: "Robin" <robin @ infusedlight.net>


Please choose one posting address and stick with it.

Thank you.


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


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

Date: 11 Apr 2004 12:59:07 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Random Qs: overloading ==; import
Message-Id: <c5bfer$grr$1@mamenchi.zrz.TU-Berlin.DE>

kj  <socyl@987jk.com> wrote in comp.lang.perl.misc:
> 
> 
> I recently came across the following (somewhat tongue-in-cheek) Perl
> code.
> 
>     #!/usr/bin/perl -w
>     use strict;
> 
>     BEGIN
>     {
>       package True;

[...]

>       sub equals
>       {
>         my ($x, $y, $swap) = @_;
> 
>         $y ? True->new() : False->new();
>       }
>     }

[...]

     BEGIN {
         import True;
         import False;
     }

[...]

> I have some questions about this code:
> 
> 1. Why do the equals subs have a third (unused) argument $swap?

See perldoc overload.  The third parameter is handed in by the overload
mechanism.  It indicates that the agruments have been swapped against
the original order.  This happens when the first operand of an overloaded
operator is unblessed.  Since the result of 'equals' doesn't depend
on the order of operands, it can be ignored.

> 2. In this case, what would be the difference between "import True;"
>    and "use True;"?

See "perldoc use".

"use" would try to load "True.pm" and fail, so only "import()" is used.

>                        Is "import True;" equivalent to
>    "True->import();"?

Mostly.  See "perldoc perlobj".

>                        And why are the import statements placed inside
>    a BEGIN block?

As you have guessed, they replace "use" statements.  Since "use" calls
->import at compile time, so should the replacement.

Your questions have little to do with the specifics of the True and False
classes (most of which I snipped).  These techniques apply when modules
that would normally live in an external file are incorporated into the main
program.

Anno


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

Date: Sun, 11 Apr 2004 16:25:35 +0200
From: Mike Mimic <ppagee@yahoo.com>
Subject: Re: Regexp guestion
Message-Id: <jBcec.760$37.97469@news.siol.net>

Hi!

Peter J. Acklam wrote:
> Mike Mimic <ppagee@yahoo.com> wrote:
>>And which of those is the fastest?
> 
>     perldoc Benchmark

Thanks. I have tested it and to my suprise
I found out that my version is the fastest
(although it uses while loop). I thought
it will be yours.


Mike


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

Date: Sun, 11 Apr 2004 10:54:22 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: J Krugman <jkrugman@yahoo.com>
Subject: Re: Returning multiple values
Message-Id: <Pine.SGI.3.96.1040411104502.183234B-100000@vcmr-64.server.rpi.edu>

[posted & mailed]

On Sun, 11 Apr 2004, J Krugman wrote:

>In <4078A144.7050107@rochester.rr.com> Bob Walton <invalid-email@rochester.rr.com> writes:
>
>>Try:
>>
>>     my $n=()=foo();
>
>OK, but what does it mean?  What does perl do when it executes the

Briefly put, there are a few things you need to know here.  First, that
assignment works right-to-left, so

  my $n = () = foo();

is, precedence-wise:

  my $n = ( () = foo() );

Second, you need to know that list-assignment:

  @a = foo();
  ($b, $c) = foo();
  ($d) = foo();
  # and even
  () = foo();

will, in scalar context, return the number of values found on the
right-hand side of the assignment.  Thus, if foo() returns 10 values, then

  $x = @a = foo();
  $x = ($b, $c) = foo();
  $x = ($d) = foo();
  $x = () = foo();

all store 10 in $x, regardless of how many variables are being given
values from foo()'s return list.

And as an exercise to the reader, what do you expect

  $a = ($b,$c) = ($d,$e,$f) = ('a' .. 'z');

to store in each of those variables?  Remember precedence:

  $a = (
    ($b,$c) = (
      ($d,$e,$f) = ('a' .. 'z')
    )
  );

(And also note that a list assignment in list context merely returns the
left-hand side, NOT the right-hand side.)

-- 
Jeff Pinyan             RPI Acacia Brother #734             2004 IT Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Sun, 11 Apr 2004 14:23:53 +0000 (UTC)
From: J Krugman <jkrugman@yahbitoo.com>
Subject: strict irony
Message-Id: <c5bkdp$3oj$1@reader1.panix.com>



use strict;

print "Ain't it ironic?\n"        if strict;
print "The things you learn...\n" if BAREWORD;
print "What's going on here?\n"   if bewildered;

# but if this line is uncommented, script won't compile:
# my $x = BAREWORD;

# ...will wonders ever cease?
#
# jill
-- 
To  s&e^n]d  me  m~a}i]l  r%e*m?o\v[e  bit from my a|d)d:r{e:s]s.



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

Date: Sun, 11 Apr 2004 11:26:42 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: strict irony
Message-Id: <Nsdec.92$2Z6.44594@news20.bellglobal.com>


"J Krugman" <jkrugman@yahbitoo.com> wrote in message
news:c5bkdp$3oj$1@reader1.panix.com...
>
>
> use strict;
>
> print "Ain't it ironic?\n"        if strict;
> print "The things you learn...\n" if BAREWORD;
> print "What's going on here?\n"   if bewildered;
>
> # but if this line is uncommented, script won't compile:
> # my $x = BAREWORD;
>
> # ...will wonders ever cease?

What wonders? That you're using strictures but not warnings?

Matt




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

Date: Sun, 11 Apr 2004 15:51:26 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: strict irony
Message-Id: <407966a4.156183953@news.erols.com>

J Krugman <jkrugman@yahbitoo.com> wrote:

: use strict;
: 
: print "Ain't it ironic?\n"        if strict;
: print "The things you learn...\n" if BAREWORD;
: print "What's going on here?\n"   if bewildered;
: 
: # but if this line is uncommented, script won't compile:
: # my $x = BAREWORD;

The 'if' modifiers are being optimized away.  Why the optimizing phase
would turn a blind eye to barewords under strict subs, I don't know.

Compounding the mystery, adding "use warnings;" causes the missing
"Bareword not allowed" compilation errors to surface.  Changing 'if' to
'unless' causes compilation errors as well.

A most curious discovery.



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

Date: Sun, 11 Apr 2004 16:08:39 +0000 (UTC)
From: J Krugman <jkrugman@yahbitoo.com>
Subject: Re: strict irony
Message-Id: <c5bqi7$5ou$1@reader1.panix.com>

In <Nsdec.92$2Z6.44594@news20.bellglobal.com> "Matt Garrish" <matthew.garrish@sympatico.ca> writes:

>"J Krugman" <jkrugman@yahbitoo.com> wrote in message
>news:c5bkdp$3oj$1@reader1.panix.com...
>>
>>
>> use strict;
>>
>> print "Ain't it ironic?\n"        if strict;
>> print "The things you learn...\n" if BAREWORD;
>> print "What's going on here?\n"   if bewildered;
>>
>> # but if this line is uncommented, script won't compile:
>> # my $x = BAREWORD;
>>
>> # ...will wonders ever cease?

>What wonders? That you're using strictures but not warnings?

The code above should not compile, irrespective of whether warnings
are on or off.  In fact, I just learned that it's a bug, not a
feature:  http://tinyurl.com/3gfcr .

jill
-- 
To  s&e^n]d  me  m~a}i]l  r%e*m?o\v[e  bit from my a|d)d:r{e:s]s.



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

Date: Sun, 11 Apr 2004 12:12:22 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: strict irony
Message-Id: <Pine.SGI.3.96.1040411120601.184708A-100000@vcmr-64.server.rpi.edu>

On Sun, 11 Apr 2004, Jay Tilton wrote:

>J Krugman <jkrugman@yahbitoo.com> wrote:
>
>: use strict;
>: 
>: print "Ain't it ironic?\n"        if strict;
>: print "The things you learn...\n" if BAREWORD;
>: print "What's going on here?\n"   if bewildered;
>
>The 'if' modifiers are being optimized away.  Why the optimizing phase
>would turn a blind eye to barewords under strict subs, I don't know.

I'd have to look at the source to see why, but I'm guessing that the "if
BAREWORD" construction *is* being optimized away.

>Compounding the mystery, adding "use warnings;" causes the missing
>"Bareword not allowed" compilation errors to surface.  Changing 'if' to
>'unless' causes compilation errors as well.

That's because 'unless' is merely 'if not ...', so there is no longer an
"if BAREWORD" construct, there is an "if not BAREWORD", which is
apparently not covered by this optimization.

This optimization is, of course, compile-time, so don't be surprised that

  use strict;
  print "ok\n" if FALSE;
  use constant FALSE => 0;

prints "ok".  The removal of the conditional happens before the 'use
constant' line is reached.

-- 
Jeff Pinyan             RPI Acacia Brother #734             2004 IT Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Sun, 11 Apr 2004 12:15:24 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: strict irony
Message-Id: <qaeec.127$2Z6.51822@news20.bellglobal.com>


"Jay Tilton" <tiltonj@erols.com> wrote in message
news:407966a4.156183953@news.erols.com...
> J Krugman <jkrugman@yahbitoo.com> wrote:
>
> : use strict;
> :
> : print "Ain't it ironic?\n"        if strict;
> : print "The things you learn...\n" if BAREWORD;
> : print "What's going on here?\n"   if bewildered;
> :
> : # but if this line is uncommented, script won't compile:
> : # my $x = BAREWORD;
>
> The 'if' modifiers are being optimized away.  Why the optimizing phase
> would turn a blind eye to barewords under strict subs, I don't know.
>

Unless I'm missing something obvious, I don't see the issue here. Until you
attempt to assign a bareword to a variable, why would strictures complain?

Matt




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

Date: Sun, 11 Apr 2004 12:44:52 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: strict irony
Message-Id: <Pine.SGI.3.96.1040411124215.185380A-100000@vcmr-64.server.rpi.edu>

On Sun, 11 Apr 2004, Matt Garrish wrote:

>"Jay Tilton" <tiltonj@erols.com> wrote in message
>news:407966a4.156183953@news.erols.com...
>> J Krugman <jkrugman@yahbitoo.com> wrote:
>>
>> : use strict;
>> :
>> : print "Ain't it ironic?\n"        if strict;
>> : print "The things you learn...\n" if BAREWORD;
>> : print "What's going on here?\n"   if bewildered;
>> :
>> : # but if this line is uncommented, script won't compile:
>> : # my $x = BAREWORD;
>>
>> The 'if' modifiers are being optimized away.  Why the optimizing phase
>> would turn a blind eye to barewords under strict subs, I don't know.
>
>Unless I'm missing something obvious, I don't see the issue here. Until you
>attempt to assign a bareword to a variable, why would strictures complain?

Because 'strict "subs"' is supposed to behave this way:

       "strict subs"
         This disables the poetry optimization, generating a compile-time
         error if you try to use a bareword identifier that's not a sub-
         routine, unless it is a simple identifier (no colons) and that it
         appears in curly braces or on the left hand side of the "=>" sym-
         bol.

and

  if (foo) { ... }

is in direct opposition to the rules stated.

-- 
Jeff Pinyan             RPI Acacia Brother #734             2004 IT Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Sun, 11 Apr 2004 17:48:16 GMT
From: Glenn Catlin <gcatlin@ix.netcom.com>
Subject: Where To Go For Classroom Training in CGI?
Message-Id: <MPG.1ae34ebc9f3cabb49896e8@news.east.earthlink.net>

I work in Philadelphia.  At the job, we have no one on staff with skill 
in Common Gateway Interface (CGI) and want to send a couple of people 
for classroom training for it.  I found a handful of local classroom 
training centers that offer PERL classes, but none seem to fully cover 
CGI.  If we can't find local training, we may need to fly our folks out 
of town for training.  Can anyone recommend a good training center in 
the U.S. for this?

Glenn
Philadelphia PA


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

Date: Sun, 11 Apr 2004 13:29:49 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Why are arrays and hashes this way?
Message-Id: <hLbec.21415$hd3.3015@nwrddc03.gnilink.net>

Uri Guttman wrote:
>>>>>> "AQ" == Ala Qumsieh <xxala_qumsiehxx@xxyahooxx.com> writes:
>
>> Xavier Noria wrote:
>   >> Does anybody know why structures were designed so that they
>   could just >> hold scalars?
>
> and even without that, it makes very good sense. the problem with
> storing a real hash where a scalar is, is how do you store it? the
> slot in an SV can hold a single item (a scalar) so what would you put
> there to represent a hash? and if any of those hash elements was a
> hash, all memory hell breaks out. in c, you can only do multidim
> arrays of known element size. with perl you can have each thing at
> any level be any thing of any size. so the win is major flexibility
> at a cost of understanding and dealing with refs. not a bad tradeoff
> IMO.

First I was thinking the same but on second thought that is really an
implementation detail of the compiler that can and should be hidden from the
user of the language.
While I agree that sometimes a language designer has to compromise because
of implementation considerations, in general that should not be the guiding
principle for designing a computer language.
Otherwise we would still be stuck with C, a languages whos features can
easily be translated one-to-one into assembler code. And which I refuse to
call "higher level" because it is too close to the computer architecture,
thus leaving the programmer with the burden of translating his problem into
too low a detail and thinking in computer architecture terms instead of in
problem area terms.
This may be fine for implementing an operating system, but it is an
unecessary burden for application programming.

In some areas Perl went beyond C, e.g. wrt. memory management for arrays and
hashes. They are just there, the programmer doesn't have to worry about
pre-allocating memory, enlarging them, or releasing them when not needed any
longer. It is a pitty that Larry didn't go all the way and eliminated the
concept of pointers (aka references) altogether. Technically there is no
need for them, the compiler could manage them automatically and hide them
from the user.

The one exception would be how to realize a call-by-reference if there are
no references in the language. However even that can be solved on the
language level by an additional keyword like e.g. "VAR" like in Pascal which
would indicate to the compiler that this parameter is call-by-reference
rather then call-by-value. Again, no need for an explicit notion ("&foobar")
of pointers/references in the technical sense.

jue




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

Date: Sun, 11 Apr 2004 15:48:10 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Why are arrays and hashes this way?
Message-Id: <2fii70tgvh7dotchh0d8fcbn1dojmhqueh@4ax.com>

On Sun, 11 Apr 2004 06:47:27 GMT, Uri Guttman <uri@stemsystems.com>
wrote:

>  AQ> AFAIK, that was how Larry Wall originally designed it, and it stayed
>  AQ> this way for backward compatibility. The introduction of reference
>  AQ> with Perl5 was specifically targeted at adding the ability to build
>  AQ> nested data structures.
>
>and even without that, it makes very good sense. the problem with

Indeed! 

As a side note, even if I have not had any exposure to Perl4 but in
terms of corrections to old(-fashioned)/obsolete scripts, I'm
fascinated by the way these extremely powerful features were added in
a manner not only backwards-compatible with previous relases of the
language, but even consistent with them, that is with Perl's basic
syntax that we all, presumably, appreciate so much!

>storing a real hash where a scalar is, is how do you store it? the slot
>in an SV can hold a single item (a scalar) so what would you put there
>to represent a hash? and if any of those hash elements was a hash, all
>memory hell breaks out. in c, you can only do multidim arrays of known

Well, as far as the UI is concerned the "look and feel" of references
is exacly this, i.e., loosely speaking (about a subset of the meanings
that can be given to refs), of "arrays and hashes that can be stored
into a single scalar variable".

IMHO the only situation when the fake nature of refs as nested
structures becomes evident is with "copy": it's not so bad in the end,
and we all do such things routinely either with our own handmade
solutions or by means of a cloning module, but that's it!

Now that I come to think of this, IMHO it would be fine if an
assignement operator existed (what about ':=') that does an automatic
recursive copy/cloning of its RHS. Or even better, an operator to
return such a clone... what about:

  <-

Hmmm, no, would be an hell for a parser to tell from "less than,
minus",

  <--

no, same cmt,

  <=

no, already taken! (and context wouldn't help much here, I guess),

  <==

Hmmm, well, what about this?

  my @AoA = ([1,0], [0,1]);
  my @new_AoA = <== @AoA;
  $new_AoA[0][1]=1; # it's now ([1,1], [0,1]), @AoA unchanged

>element size. with perl you can have each thing at any level be any
>thing of any size. so the win is major flexibility at a cost of
>understanding and dealing with refs. not a bad tradeoff IMO.
                                      ^^^^^^^^^^^^^^^^^^^^^^

Definitely, IMO too!

Also, it seems that in Perl6 dealing with references will be made much
more transparent, won't it?


Michele,
whose judgement capabilities may be strongly biased/injured by our
traditional Easter lunch...
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: Sun, 11 Apr 2004 15:34:55 +0100
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Why are arrays and hashes this way?
Message-Id: <pkent77tea-0C4476.15345511042004@pth-usenet-02.plus.net>

In article <31a13074.0404101540.504a23e6@posting.google.com>,
 fxn@hashref.com (Xavier Noria) wrote:

> When I introduce references the first thing I mention is that they
> allow us to build nested structures. However, the importance of that
> feature is a consequence of the fact that structures cannot be nested
> themselves.

They can, indeed. I haven't yet read the other 4 posts showing up in 
this thread but I'll guess that they will point out that:

a) references are scalars
b) the values in hashes and arrays are scalars
therefore, using some Ancient Greek logic :-)
c) hashes and arrays may contain other hashes or arrays by holding 
references to them

See the perlreftut page for more.

E.g.

my %nest = (
   foo => [
      1, 2, { x => 'y'}, [ 'r' ]
   ],
   bar => {
      baz => 'qux',
      quux => [
         'l'
      ],
   }
);
print $nest{bar}{quux}[0] . "\n";
print $nest{foo}[2]{x} . "\n";
__END__

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

Date: Sun, 11 Apr 2004 15:39:16 +0100
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Why are arrays and hashes this way?
Message-Id: <pkent77tea-9A0781.15391611042004@pth-usenet-02.plus.net>

In article <31a13074.0404101540.504a23e6@posting.google.com>,
 fxn@hashref.com (Xavier Noria) wrote:

> When I introduce references the first thing I mention is that they
> allow us to build nested structures. However, the importance of that
> feature is a consequence of the fact that structures cannot be nested
> themselves.
> 
> Does anybody know why structures were designed so that they could just
> hold scalars?

Oh, I see now. I misunderstood what you were getting at. Don't mind me, 
nothing to see here, move along now... :-)

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

Date: Sun, 11 Apr 2004 15:27:48 +0100
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Win32::OLE / WMEncoderAgent issue
Message-Id: <pkent77tea-8A0914.15274711042004@pth-usenet-02.plus.net>

In article <c576kb$2vl$1@nntp0.reith.bbc.co.uk>,
 simonl@is.bbc.co.uk (Simon Lockhart) wrote:

> In article <pkent77tea-9391DE.19035009042004@pth-usenet-02.plus.net>,
> pkent  <pkent77tea@yahoo.com.tea> wrote:
> >FWIW looking at Real's website it seems that Helix can encode Windows 
> >Media, and Helix appears to run on Unix :-)
> 
> It can? I've not seen that - URL?

Well I was looking at 
http://www.realnetworks.com/products/server/features.html which says 
Helix Universal Server can deliver Windows Media... I'd assumed that it 
could also encode it because of this bit: "Interoperability with all 
default Microsoft codecs shipped with Windows Media Player since version 
6.4" ... but on re-reading I get the feeling that encoding is separate 
from delivery; possibly done with RealProducer (formerly Helix Producer, 
apparently), the windows-based encoders or some other tool. So, maybe 
that isn't any help to you :-/ I suppose I should know a bit more about 
this as my orkplace does a bit of streaming and clip serving.

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

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


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