[28193] in Perl-Users-Digest
Perl-Users Digest, Issue: 9557 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 3 21:05:53 2006
Date: Thu, 3 Aug 2006 18: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 Thu, 3 Aug 2006 Volume: 10 Number: 9557
Today's topics:
5 uncommonly known things about Perl <tfurnitu@cisco.com>
Re: 5 uncommonly known things about Perl axel@white-eagle.invalid.uk
Re: 5 uncommonly known things about Perl usenet@DavidFilmer.com
Re: 5 uncommonly known things about Perl <uri@stemsystems.com>
clpm style rant (was Re: How probably not to hand over <uri@stemsystems.com>
Re: executing perl script without .pl extension <mgarrish@gmail.com>
Re: h2xs -Oxan ... fails when processing GNU/Linux /usr <benmorrow@tiscali.co.uk>
Re: h2xs -Oxan ... fails when processing GNU/Linux /usr <ramcgowan@comcast.net>
Re: h2xs -Oxan ... fails when processing GNU/Linux /usr <nospam-abuse@ilyaz.org>
Re: How probably not to hand over a variable from one p <tzz@lifelogs.com>
Re: How probably not to hand over a variable from one p <jgibson@mail.arc.nasa.gov>
Re: How probably not to hand over a variable from one p axel@white-eagle.invalid.uk
Re: How probably not to hand over a variable from one p <1usa@llenroc.ude.invalid>
Re: How probably not to hand over a variable from one p <uri@stemsystems.com>
Re: How to "convert" a string into a variable name? <nospam@comcast.net>
Re: How to "convert" a string into a variable name? <1usa@llenroc.ude.invalid>
Re: Learning Typeglobs, Symbol Tables and the More Obsc anno4000@radom.zrz.tu-berlin.de
light weight references and arrays xhoster@gmail.com
Re: light weight references and arrays <uri@stemsystems.com>
Re: light weight references and arrays <rvtol+news@isolution.nl>
Re: light weight references and arrays xhoster@gmail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 03 Aug 2006 14:22:32 -0700
From: Taher <tfurnitu@cisco.com>
Subject: 5 uncommonly known things about Perl
Message-Id: <44D26918.46CD70E8@cisco.com>
Hi ,
I was once asked to name some uncommonly known things about Perl , thus
I thought that it might be an interesting thread to start .....
Taher.
------------------------------
Date: Thu, 03 Aug 2006 21:52:42 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: 5 uncommonly known things about Perl
Message-Id: <KeuAg.12760$lv.10685@fed1read12>
Taher <tfurnitu@cisco.com> wrote:
> I was once asked to name some uncommonly known things about Perl , thus
> I thought that it might be an interesting thread to start .....
We could tell you, but then we would have to 'undef' you. :)
Axel
------------------------------
Date: 3 Aug 2006 15:07:30 -0700
From: usenet@DavidFilmer.com
Subject: Re: 5 uncommonly known things about Perl
Message-Id: <1154642850.701014.325180@h48g2000cwc.googlegroups.com>
Taher wrote:
> I was once asked to name some uncommonly known things about Perl
Perl comes with documentation (including a FAQ). This doesn't seem to
be commonly known...
--
David Filmer (http://DavidFilmer.com)
------------------------------
Date: Thu, 03 Aug 2006 19:00:50 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: 5 uncommonly known things about Perl
Message-Id: <x7bqr1zaot.fsf@mail.sysarch.com>
>>>>> "T" == Taher <tfurnitu@cisco.com> writes:
T> I was once asked to name some uncommonly known things about Perl , thus
T> I thought that it might be an interesting thread to start .....
i know several uncommon things but i don't have enough room in the
margin to write them.
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: Thu, 03 Aug 2006 18:48:14 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: clpm style rant (was Re: How probably not to hand over a variable)
Message-Id: <x7k65pzb9t.fsf_-_@mail.sysarch.com>
>>>>> "ASU" == A Sinan Unur <1usa@llenroc.ude.invalid> writes:
ASU> <rant> I consider this poster a good example of what happens when
ASU> people are not immediately hit by a clue-by-four. I mean, look at
ASU> this thread: A bunch of us patiently explaining the most
ASU> elementary concepts that one ought to learn by reading a book,
ASU> and what do we get in return? "Perl should be smart enough"? And
ASU> a complete resistance to learning.
ASU> Perl, just like any other programming language, has rules. Those
ASU> rules make the language. The programmer learns those rules, and
ASU> abides by them. If said programmer does not like the rules of a
ASU> language, the programmer should look for another languages which
ASU> is more to his liking.
and a recent thread was all about how we are an arrogant bunch of
assholes. so how do you handle a case like this? i see a long thread
with many patient answers and an OP who seems to not grasp what he is
being told and obviously has some very broken concepts of perl (possibly
from that unnamed 'good perl book' he partly read. so do we keep telling
him what to do? write his code for him and he won't learn it? encourage
him to read more first? almost any result of this will make us look bad
as we gang up telling him what to do. so to those who flamed me recently
(and plonked, ain't had that in a while), where are you in thepppppppse types
of threads? typically, the nice guys not only finish last, they don't
even show up at the starting line. it does take a thick skin and lots of
perserverence to help here for free. so to those who know our style, go
do it yourself. join the perl beginner's list, post here more
often. answer all those FAQ (and correctly!) over and over. i don't feel
any shame in my perl teaching style. many have paid me for this and
enjoy it my work, strong opinions and all. i offer it here for free so
you can ignore me at your peril or choice. note that i was one of the
technical editors of PBP and if you respect damian, maybe some of that
should reflect onto my work here. you might even want to read what he
said about me in his acknowledgements. i have professional opinions that
have been developed over 32 years of coding on more different kinds of
projects and systems than most of you have ever heard of. i don't come
here for glory or your adulation. i come here to give out my experience
where i feel it can be used or learned from. take it is as i give it or
plonk me as i don't care as long as long as i can help some perl hackers
get better. people who know me well know that i am who i am and you are
not going to change me. better to change yourself.
as for helping the perl community, this is only one small place where i
do this. check my web site for all the many things i help with in many
places. i don't need nor care about random flames about my work in this
group. when you volunteer for the perl foundation, raise funds, give
talks, write articles, modules, work at yapc, etc. then you may have
some platform to comment on what i do here. arrogance is part and parcel
of being good and being able to back it. i promote my modules because i
know how good they are and how well they solve their specific problem
domains. i don't make a dime from them so why is that a problem for
some?
now i feel better (in more ways than one!)
and now back to our usual kindergarten dynamic of a perl newsgroup. i
just feel like a 6th grader here.
uri
PS. hopefully the twit who plonked me recently will read this, but i
doubt it.
--
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: 3 Aug 2006 13:58:03 -0700
From: "Matt Garrish" <mgarrish@gmail.com>
Subject: Re: executing perl script without .pl extension
Message-Id: <1154638683.085425.48580@p79g2000cwp.googlegroups.com>
tweaky@gmail.com wrote:
[please learn how to post]
> Matt Garrish wrote:
>
> > I always enjoy the "I don't know what I'm talking about but I'll
> > pretend it was working last week" approach to questions, though. : )
> I appreciate everyone's responses, and yes, in retrospect, this was the
> incorrect group to post in, but the quoted response was completely
> inappropriate.
If you don't like your free advice, go suck a coconut...
Matt
------------------------------
Date: Thu, 3 Aug 2006 17:59:49 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: h2xs -Oxan ... fails when processing GNU/Linux /usr/include/stdio.h
Message-Id: <5lm9q3-44m.ln1@osiris.mauzo.dyndns.org>
Quoth "freeholder" <ramcgowan@comcast.net>:
> I'm attempting to build a module created by an associate that works
> fine on a Solaris 9 system. This is not going to actually be packaged
> up in any way for distribution, it's for internal use on a few systems,
> so we've chosen to simply build the module from scratch for the two
> environments. This may not be the best decision, but that's where we
> are now.
Assuming the header declares the same functions on both systems, why not
just copy the XS file from one to the other, and then port if necessary?
Ben
--
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes, [ Heracles shoots Vulture with arrow. Vulture bursts into ]
'Alcestis') [ flame, and falls out of sight. ] benmorrow@tiscali.co.uk
------------------------------
Date: 3 Aug 2006 16:13:09 -0700
From: "freeholder" <ramcgowan@comcast.net>
Subject: Re: h2xs -Oxan ... fails when processing GNU/Linux /usr/include/stdio.h
Message-Id: <1154646789.347396.321420@h48g2000cwc.googlegroups.com>
An excellent idea, which I had tried yesterday evening. There were a
slew of compiler errors, though. But your idea did lead to our
managing to get the thing to compile, by going back to the XS file and
cleaning it up, which is to say we used it as an example and removed
all the extra stuff h2xs had put in, essentially building the XS file
by hand.
This got rid of all the compiler errors and we have an extension that
builds. Unfortunately, it segfaults, but that is not an issue for this
list.
Thanks for the suggestion.
Bob
Ben Morrow wrote:
> Quoth "freeholder" <ramcgowan@comcast.net>:
> > I'm attempting to build a module created by an associate that works
> > fine on a Solaris 9 system. This is not going to actually be packaged
> > up in any way for distribution, it's for internal use on a few systems,
> > so we've chosen to simply build the module from scratch for the two
> > environments. This may not be the best decision, but that's where we
> > are now.
>
> Assuming the header declares the same functions on both systems, why not
> just copy the XS file from one to the other, and then port if necessary?
>
> Ben
>
> --
> Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
> From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
> (Ted Hughes, [ Heracles shoots Vulture with arrow. Vulture bursts into ]
> 'Alcestis') [ flame, and falls out of sight. ] benmorrow@tiscali.co.uk
------------------------------
Date: Fri, 4 Aug 2006 00:17:33 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: h2xs -Oxan ... fails when processing GNU/Linux /usr/include/stdio.h
Message-Id: <eau3mt$1vav$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
freeholder
<ramcgowan@comcast.net>], who wrote in article <1154623672.926932.138370@i3g2000cwc.googlegroups.com>:
> $ h2xs -Oxan CLIEXT cliext.h
> Defaulting to backwards compatibility with perl 5.8.4
> If you intend this module to be compatible with earlier perl versions,
> please
> specify a minimum perl version with the -b option.
>
> Overwriting existing CLIEXT!!!
> Writing CLIEXT/ppport.h
> Scanning typemaps...
> Scanning /usr/local/perl/lib/5.8.4/ExtUtils/typemap
> Scanning cliext.h for functions...
> Expecting parenth after identifier in `struct _IO_FILE_plus
> _IO_2_1_stdin_;
> extern struct _IO_FILE_plus _IO_2_1_stdout_;
You are not supposed to do this. Run h2xs on a file which defines the
API. So replace your cliext.h by
#include <stdio.h>
#include <cliext_api.h>
and run h2xs on cliext_api.h.
Anyway, Perl is not (very) compatible with stdio, so make sure the API
does not use stdio.h; for this, you may need to break cliext_api.h
into more parts, keeping the parts accessible from Perl separate from
parts accessing stdio.
Hope this helps,
Ilya
------------------------------
Date: Thu, 03 Aug 2006 14:08:56 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: How probably not to hand over a variable from one perl script to another
Message-Id: <g69u04tg093.fsf@CN1374059D0130.kendall.corp.akamai.com>
On 3 Aug 2006, tinnews@isbd.co.uk wrote:
> The problem (from where I'm looking) with perl is how many, many ways
> there are of doing things that hide what is going on, e.g. the
> implicit use of $_.
>
> Being used to more picky languages (like C and Java) I never feel safe
> with all these things happening 'by themselves'.
You must dislike natural languages then. "it" is a perfect example:
Bring me the paper. It is $1. Don't forget to pay for it.
versus:
Bring me the paper. The paper is $1. Don't forget to pay for the
paper.
$_ and such implicit contexts work the way "it" does in English.
I consider Perl a good "caveman" language because it doesn't require
you to name things, only to use them :) Naming things is tedious and
often unnecessary.
Another example:
Do this 10 times. (foreach (1..10) { do something })
[$_ will hold the number]
versus:
Start with i at 1. While i is not 10 or more, increment i by 1. (We
know how this looks in C.)
[i will hold the number]
Ted
------------------------------
Date: Thu, 03 Aug 2006 12:08:20 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: How probably not to hand over a variable from one perl script to another
Message-Id: <030820061208201603%jgibson@mail.arc.nasa.gov>
In article <44d20ac1@news1.ethz.ch>, Markus Hänchen
<youcontrol@hispeed.ch> wrote:
> > A better method is to use one of the standard methods for data passing:
> > files, pipes, sockets, shared memory, ....
>
> I guess modules, as suggested by other people, fall also into this category?
No. Modules are linked with your program and do not require
inter-process communication (IPC) for passing data. They can use
subroutine or method arguments or global variables.
------------------------------
Date: Thu, 03 Aug 2006 21:24:29 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: How probably not to hand over a variable from one perl script to another
Message-Id: <hQtAg.12707$lv.11149@fed1read12>
Ted Zlatanov <tzz@lifelogs.com> wrote:
> On 3 Aug 2006, youcontrol@hispeed.ch wrote:
>>> Note this is really a question about command line arguments, not
>>> passing perl variables between perl scripts.
>> I am realising this. In other words, instead of writing the values of
>> the variables to a temp file (my original approach), I am writing them
>> to the command line and reading them back from there, probably a
>> better approach but stil a pain for arrays and hashes (which I have to
>> take apart and reassemble for both approaches).
> If you need multi-level data structures, write them to a file using
> YAML, XML, or something like that. Please don't try to make your own
> data language, as appealing as that is to most programmers.
> You can easily pass lists and 1-level hashes (just key/value, not
> complex values that are lists or hashes in themselves) with the
> AppConfig/Getopt modules from the command line, but if you expect your
> program to ever need complex data, just bite the bullet now.
> Finally, do NOT write your file as executable code so you can then run
> eval() on it. Bad idea, even for advanced programmers.
I am curious as to why this is a bad idea. I would have thought that
using Data::Dumper to save data and then eval'ing it would be the idea
solution for passing such things as arrays and hashes.
Axel
------------------------------
Date: Thu, 03 Aug 2006 22:29:53 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: How probably not to hand over a variable from one perl script to another
Message-Id: <Xns9814BC4454BFEasu1cornelledu@127.0.0.1>
axel@white-eagle.invalid.uk wrote in
news:hQtAg.12707$lv.11149@fed1read12:
> Ted Zlatanov <tzz@lifelogs.com> wrote:
...
>> Finally, do NOT write your file as executable code so you can then
>> run eval() on it. Bad idea, even for advanced programmers.
>
> I am curious as to why this is a bad idea. I would have thought that
> using Data::Dumper to save data and then eval'ing it would be the idea
> solution for passing such things as arrays and hashes.
Well, for one thing, there is no way to ensure that what you are eval'ing
is what you want to eval.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Thu, 03 Aug 2006 18:27:56 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: How probably not to hand over a variable from one perl script to another
Message-Id: <x7odv1zc7n.fsf@mail.sysarch.com>
>>>>> "MH" == Markus Hänchen <youcontrol@hispeed.ch> writes:
MH> Thanks for the tutorials. About the 'throwing it at the wall', I
MH> did read the first half of a good book on Perl (and browse and
MH> search it as well as the internet before posting here) but there
MH> this saying about learning by doing and learning by making
MH> mistakes.
it probably wasn't a good perl book if you learned all those poor perl
coding ideas. what book was it? there are tons of bad perl books and web
tutorials out there.
MH> I know how to get an item out of an array but if the array contains
MH> only one element calling the array without any arguments should give
MH> me that element, Perl should be smart enough to do this (and I guess
MH> it would be, were it not for the fact that @arrayname is reserved to
MH> give me the number of elements of an array, which I did not know since
MH> I always used $#arrayname to get the length of an array).
you have some major flaws in your perl understanding there. you don't
understand list vs scalar context and you don't 'call' an array. @array
is NOT reserved for anything. it is the array itself. but when it is
evaluated in a scalar context (see context is important in perl, very
important), it is the number of elements in the array.
as paul said, read some good tutes and books. learn.perl.org is a good
site to start with.
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: Thu, 3 Aug 2006 20:24:30 -0400
From: "thrill5" <nospam@comcast.net>
Subject: Re: How to "convert" a string into a variable name?
Message-Id: <Naydnds0WNMhDk_ZnZ2dnUVZ_umdnZ2d@comcast.com>
I think this is what you had in mind:
$TempOut = 25;
$name = "TempOut";
print $$name;
Scott
"Markus Hänchen" <youcontrol@hispeed.ch> wrote in message
news:44d1079b@news1.ethz.ch...
>> While it's good that you found *a* solution on your own, I must caution
>> you that this is a *bad* solution. Very very bad. eval() is a powerful
>> but dangerous function. If at any point, the string you're eval'ing
>> contains input from a user, you could do some serious damage to your
>> program and to your system.
>>
>> A *good* solution is to _not_ try to create a variable name out of a
>> string. Instead, store all the "variables" you want to access this way
>> in a hash. The keys are whatever you currently have as a variable
>> name, and the value is the value you wanted to assign to that variable.
>> Using that method, your example above becomes:
>>
>> my %value_of
>> $value_of{TempOut} = 25;
>> $name = 'Temp' . 'Out';
>> print $value_of{$name};
>
> Thanks Paul. I really should use a hash (not least since my eval string
> gets user input...).
>
>
>
>
------------------------------
Date: Fri, 04 Aug 2006 00:34:34 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: How to "convert" a string into a variable name?
Message-Id: <Xns9814D1682D4D4asu1cornelledu@127.0.0.1>
"thrill5" <nospam@comcast.net> wrote in
news:Naydnds0WNMhDk_ZnZ2dnUVZ_umdnZ2d@comcast.com:
First, do not top-post.
> I think this is what you had in mind:
>
> $TempOut = 25;
> $name = "TempOut";
> print $$name;
Second, it has already been explained that this is not a good idea.
Please do read the FAQ:
perldoc -q "How can I use a variable as a variable name"
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: 3 Aug 2006 21:39:31 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Learning Typeglobs, Symbol Tables and the More Obscure Features?
Message-Id: <4jf8ojF79qgjU1@news.dfncis.de>
Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote in comp.lang.perl.misc:
> [A complimentary Cc of this posting was sent to
> <anno4000@radom.zrz.tu-berlin.de>], who wrote in article
> <4h29vaF1pav9iU1@news.dfncis.de>:
> > > arrays and hashes, of course, plus formats, I think. But are directory
> > > handles yet another kind of "scalar type"? I haven't found the
> answer in the
> > > docs sofar.
>
> > No, dir handles appear as a special case of file handle, both are
> > accessed through (say) *main::HANDLE{ IO} as the case may be.
>
> This is not so. Filehandles and dirhandles live in different
> namespaces. (I have no idea what *HANDLE{IO} does if both exist.)
I see. So "IO" maps to two distinct slots in a glob. Whoda thunk.
Anno
------------------------------
Date: 03 Aug 2006 18:25:30 GMT
From: xhoster@gmail.com
Subject: light weight references and arrays
Message-Id: <20060803143343.643$Hy@newsreader.com>
Arrays hold some kind of special light-weight reference to it's scalar
members, but of course the reference it holds are not held in full scalars,
as that would cause an infinite regress. Is there some way to manipulate
these light-weight references directly?
The code below makes a copy of all the data in $y:
$ perl -le 'my @x=1..10; my $y = "x"x1e7; $x[0]=$y'
This codes doesn't make a copy, but now I need to manually derefence
it when I want to retrieve it from @x:
$ perl -le 'my @x=1..10; my $y = "x"x1e7; $x[0]=\$y'
And this code just doens't work:
$ perl -le 'my @x=1..10; my $y = "x"x1e7; \$x[0]=\$y'
Can't modify single ref constructor in scalar assignment at -e line 1, at EOF
I think the above code makes it clear what I intended to do, change the SV
that a certain array slot is referencing to be a different SV. Is there a
fundamental reason that Perl cannot be made to this, or is it simply that
it hasn't been coded that way?
A similar question goes for concatenating arrays--is there a way to
accomplish something like push @x,@y but having the scalars contained in @y
be directly incorporated into the end of @x, rather than being copied into
new scalars that are on the end of @x? (unlike the original, I don't know
what syntax would be used to imply this operation)
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Thu, 03 Aug 2006 18:59:06 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: light weight references and arrays
Message-Id: <x7fygdzarp.fsf@mail.sysarch.com>
>>>>> "x" == xhoster <xhoster@gmail.com> writes:
x> I think the above code makes it clear what I intended to do, change
x> the SV that a certain array slot is referencing to be a different
x> SV. Is there a fundamental reason that Perl cannot be made to
x> this, or is it simply that it hasn't been coded that way?
i think local can do that as it will work on any element in an array or
hash. should be easy to test for your needs. perl6 can do that almost
surely as it has a bind := op.
x> A similar question goes for concatenating arrays--is there a way to
x> accomplish something like push @x,@y but having the scalars contained in @y
x> be directly incorporated into the end of @x, rather than being copied into
x> new scalars that are on the end of @x? (unlike the original, I don't know
x> what syntax would be used to imply this operation)
what you want is lazy evaluation which perl6 will also have. you can
push a whole array and only when you access that section it will it be
accessed and then via the original array (if it hasn't been modified,
copy on write rules are in effect).
of course i could be wrong this week as perl6 changes faster then a
submachine gun based tv remote control!
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: Fri, 4 Aug 2006 01:12:52 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: light weight references and arrays
Message-Id: <eau6v2.9s.1@news.isolution.nl>
xhoster@gmail.com schreef:
> Arrays hold some kind of special light-weight reference to it's scalar
> members, but of course the reference it holds are not held in full
> scalars, as that would cause an infinite regress. Is there some way
> to manipulate these light-weight references directly?
>
>
> The code below makes a copy of all the data in $y:
>
> $ perl -le 'my @x=1..10; my $y = "x"x1e7; $x[0]=$y'
>
> This codes doesn't make a copy, but now I need to manually derefence
> it when I want to retrieve it from @x:
>
> $ perl -le 'my @x=1..10; my $y = "x"x1e7; $x[0]=\$y'
>
> And this code just doens't work:
>
> $ perl -le 'my @x=1..10; my $y = "x"x1e7; \$x[0]=\$y'
> Can't modify single ref constructor in scalar assignment at -e line
> 1, at EOF
>
> I think the above code makes it clear what I intended to do, change
> the SV that a certain array slot is referencing to be a different SV.
> Is there a fundamental reason that Perl cannot be made to this, or is
> it simply that
> it hasn't been coded that way?
>
> A similar question goes for concatenating arrays--is there a way to
> accomplish something like push @x,@y but having the scalars contained
> in @y be directly incorporated into the end of @x, rather than being
> copied into new scalars that are on the end of @x? (unlike the
> original, I don't know what syntax would be used to imply this
> operation)
I think you are looking for
http://search.cpan.org/search?module=Data::Alias
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 04 Aug 2006 00:11:27 GMT
From: xhoster@gmail.com
Subject: Re: light weight references and arrays
Message-Id: <20060803201943.726$Zo@newsreader.com>
"Dr.Ruud" <rvtol+news@isolution.nl> wrote:
> xhoster@gmail.com schreef:
>
> > Arrays hold some kind of special light-weight reference to it's scalar
> > members, but of course the reference it holds are not held in full
> > scalars, as that would cause an infinite regress. Is there some way
> > to manipulate these light-weight references directly?
...
> >
> > A similar question goes for concatenating arrays--is there a way to
> > accomplish something like push @x,@y but having the scalars contained
> > in @y be directly incorporated into the end of @x, rather than being
> > copied into new scalars that are on the end of @x? (unlike the
> > original, I don't know what syntax would be used to imply this
> > operation)
>
> I think you are looking for
> http://search.cpan.org/search?module=Data::Alias
Thanks. That looks very nice, and just what I wanted.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
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 9557
***************************************