[28267] in Perl-Users-Digest
Perl-Users Digest, Issue: 9631 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 21 06:06:01 2006
Date: Mon, 21 Aug 2006 03: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 Mon, 21 Aug 2006 Volume: 10 Number: 9631
Today's topics:
-multiposted- (was: hiw do i perform this extraction) me@davidfilmer.net
-multiposted- (was: hiw do i perform this extraction) me@davidfilmer.net
A Editor Feature for Extending Selection based on Langu <xah@xahlee.org>
Re: FAQ 4.22 How do I expand function calls in a string <brian.d.foy@gmail.com>
hiw do i perform this extraction <kitcha315@gmail.com>
Re: hiw do i perform this extraction <bik.mido@tiscalinet.it>
new CPAN modules on Mon Aug 21 2006 (Randal Schwartz)
Printing to a file Or STDOUT <hal@thresholddigital.com>
Re: Printing to a file Or STDOUT <josef.moellers@fujitsu-siemens.com>
Re: Printing to a file Or STDOUT <bik.mido@tiscalinet.it>
References - problem understanding them <juergenherz@gmail.com>
Re: References - problem understanding them <David.Squire@no.spam.from.here.au>
Re: References - problem understanding them <jurgenex@hotmail.com>
Re: References - problem understanding them xhoster@gmail.com
Re: References - problem understanding them <klaus03@gmail.com>
Re: References - problem understanding them <AaronJSherman@gmail.com>
Reported (was Re: A Editor Feature for Extending) <john@castleamber.com>
Re: The DEBUG constant? <skg@mail.inf.fh-brs.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 21 Aug 2006 03:22:31 -0500
From: me@davidfilmer.net
Subject: -multiposted- (was: hiw do i perform this extraction)
Message-Id: <LdKdnVOD5-va8HTZRVn_vA@giganews.com>
"kitcha" <kitcha315@gmail.com> wrote:
>> [ snip multiposted message ]
This message has been posted more than once as separate articles:
comp.lang.perl.misc
<news:1156147939.176160.48680@h48g2000cwc.googlegroups.com>
perl.beginners
<news:1156147886.554906.43800@h48g2000cwc.googlegroups.com>
This practice, known as multiposting, is generally considered
impolite in Usenet newsgroups. For an explanation, please see:
http://www.cs.tut.fi/~jkorpela/usenet/xpost.html
--
msg_hash: 141 - 3398d91fe570e0de31430a412cf6cfeb
------------------------------
Date: Mon, 21 Aug 2006 03:22:30 -0500
From: me@davidfilmer.net
Subject: -multiposted- (was: hiw do i perform this extraction)
Message-Id: <QMKdndcoPr3b8HTZnZ2dnUVZ_76dnZ2d@giganews.com>
"kitcha" <kitcha315@gmail.com> wrote:
>> [ snip multiposted message ]
This message has been posted more than once as separate articles:
comp.lang.perl.misc
<news:1156147939.176160.48680@h48g2000cwc.googlegroups.com>
perl.beginners
<news:1156147886.554906.43800@h48g2000cwc.googlegroups.com>
This practice, known as multiposting, is generally considered
impolite in Usenet newsgroups. For an explanation, please see:
http://www.cs.tut.fi/~jkorpela/usenet/xpost.html
--
msg_hash: 0 - 3398d91fe570e0de31430a412cf6cfeb
------------------------------
Date: 20 Aug 2006 21:49:45 -0700
From: "Xah Lee" <xah@xahlee.org>
Subject: A Editor Feature for Extending Selection based on Language Syntax
Message-Id: <1156135784.964866.190530@i3g2000cwc.googlegroups.com>
can anyone give me a guide about writing a short elisp function? (for
non-emacs readers, this message will describe a editor feature i think
will be very beneficial to spread this concept.)
i want to write a function such that, when run, highlight a region
between the nearest left and right delimiters. Delimiters are any of
parenthesis, square brackets, or single and double quotes etc. When the
function is run again, it extends the selection to the next enclosing
delimiters.
So, in this way, a user can repeatedly press a keyboard shortcut and
extend the selection.
This is feature of BBEdit/TextWrangler on the Mac, which extend
selection to the nearest outer parenthesis. This is also a feature of
the Mathematica editor, which actually extend selection to the nearest
syntactical unit in the language, not just paired delimiters.
What i wanted this for is mostly in editing HTML/XML, where one press
can select the content, another press will include the enclosing tags,
another press extends the selection to the next outer content, and
another press include that tags too, and so on.
I'm a elisp newbie. Here's a simple code i have so far:
(defun d ()
"extend selection to nearest enclosing delimiters"
(interactive)
(skip-chars-backward "^<>()=E2=80=9C=E2=80=9D{}[]")
(push-mark)
(skip-chars-forward "^<>()=E2=80=9C=E2=80=9D{}[]")
(exchange-point-and-mark 1)
)
.=2E. i think i have quite a lot to go... I think this would be a great
feature for any mode, where the a keypress will highlight more
syntactical units in any language's mode. For example, suppose in
C-like language:
function f (arg1, arg2) {
line1;
line2;
}
if the cursor is at arg1, then first press will highlight the content
of the args, another press includes the parens, another press will
include the whole function. If the cursor is at line1, then it selects
that word in the line, then the line, then the whole function def body,
then including {}, then the whole function... etc in many languages.
For a xml language example, suppose we have this RSS/Atom example:
<entry>
<title>Gulliver's Travels</title>
<id>tag:xahlee.org,2006-08-21:030437</id>
<updated>2006-08-20T20:04:41-07:00</updated>
<summary>Annotated a chapter of Gulliver's Travels</summary>
<link rel=3D"alternate" href=3D"../p/Gullivers_Travels/gt3ch05.html"/>
</entry>
If the cursor is inside a tag's enclosing content, say, on the T in
Gulliver's Travels inside the <title> tag, then the repeated extension
is obvious. But however, suppose the cursor is at t in the
=E2=80=9Calternate=E2=80=9D inside the =E2=80=9Clink=E2=80=9D tag, then it =
would first select
the whole =E2=80=9Calternate=E2=80=9D word, then the whole =E2=80=9Crel=3D"=
alternate"=E2=80=9D,
then the whole link tag, then the whole content of the entry tag, then
including the =E2=80=9C<entry>=E2=80=9D tags itself.
(in short, the selection extends according to the language's syntax
tree)
Xah
xah@xahlee.org
=E2=88=91 http://xahlee.org/
------------------------------
Date: Sun, 20 Aug 2006 14:21:05 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 4.22 How do I expand function calls in a string?
Message-Id: <200820061421058863%brian.d.foy@gmail.com>
In article <slrneegc64.3bn.justin.0607@moonlight.purestblue.com>,
Justin C <justin.0607@purestblue.com> wrote:
> On 2006-08-20, PerlFAQ Server <brian@stonehenge.com> wrote:
> >
> > In most cases, it is probably easier to simply use string concatenation,
> > which also forces scalar context.
> >
> > print "The time is " . localtime . ".\n";
>
> perl -e 'print "The time is " . localtime . ".\n"'
> Warning: Use of "localtime" without parentheses is ambiguous at -e line 1.
> The time is Sun Aug 20 10:47:37 2006.
>
> Wouldn't it be better for examples to not generate warnings?
Yes, that is better. However, you must realize that warnings change
between versions of Perl so things such as this example may not have
generated a warning earlier now does.
We fix this by getting many eyes, such as yours, to constantly
scruntize the answers and to update them where appropriate.
Thanks, :)
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: 21 Aug 2006 01:12:19 -0700
From: "kitcha" <kitcha315@gmail.com>
Subject: hiw do i perform this extraction
Message-Id: <1156147939.176160.48680@h48g2000cwc.googlegroups.com>
i have a file of this format..
ModelGen Info, Time 63425843 ps, Instance Device/Device_core
00000084 E5810000 STR r0,[r1,#0]
i want the script to print an output like this
Time 63425843 ps
00000084 E5810000 STR r0,[r1,#0]
wht cmds shud i use?
------------------------------
Date: 21 Aug 2006 10:44:27 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: hiw do i perform this extraction
Message-Id: <6asie29p21o7jqld8g2c562u5eg7om29et@4ax.com>
On 21 Aug 2006 01:12:19 -0700, "kitcha" <kitcha315@gmail.com> wrote:
>i have a file of this format..
>
> ModelGen Info, Time 63425843 ps, Instance Device/Device_core
> 00000084 E5810000 STR r0,[r1,#0]
So far so fine.
>i want the script to print an output like this
>
>Time 63425843 ps
>
> 00000084 E5810000 STR r0,[r1,#0]
So far so fine.
>wht cmds shud i use?
What have you tried thus far? Which is your perl level? Do you know
how to open() a file and read it line by line? At this point I'd
suggest a pattern match, and/or split(), see
perldoc -f m
perldoc -f split
I hope that you know at least how to print() out the desired output.
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: Mon, 21 Aug 2006 04:42:07 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Mon Aug 21 2006
Message-Id: <J4Bzq7.n4B@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
App-Trace-0.50
http://search.cpan.org/~spadkins/App-Trace-0.50/
Embedded debug statements, including call/return tracing
----
Array-Object-0.01
http://search.cpan.org/~rhundt/Array-Object-0.01/
Array Object
----
BBS-UserInfo-0.01
http://search.cpan.org/~gslin/BBS-UserInfo-0.01/
Base class of BBS::UserInfo::XXX
----
BBS-UserInfo-Maple3itoc-0.01
http://search.cpan.org/~gslin/BBS-UserInfo-Maple3itoc-0.01/
Get user information of Maple3itoc-style BBS
----
BBS-UserInfo-SOB-0.01
http://search.cpan.org/~gslin/BBS-UserInfo-SOB-0.01/
Get user information of SOB-style BBS
----
BBS-UserInfo-Wretch-0.01
http://search.cpan.org/~gslin/BBS-UserInfo-Wretch-0.01/
Get user information of Wretch-style BBS
----
BBS-UserInfo-Wretch-0.02
http://search.cpan.org/~gslin/BBS-UserInfo-Wretch-0.02/
Get user information of Wretch-style BBS
----
BBS-UserInfo-Wretch-0.03
http://search.cpan.org/~gslin/BBS-UserInfo-Wretch-0.03/
Get user information of Wretch-style BBS
----
Cache-Static-0.9902
http://search.cpan.org/~brianski/Cache-Static-0.9902/
Caching without freshness concerns
----
Cache-Static-0.9903
http://search.cpan.org/~brianski/Cache-Static-0.9903/
Caching without freshness concerns
----
Cache-Static-0.9904
http://search.cpan.org/~brianski/Cache-Static-0.9904/
Caching without freshness concerns
----
Chart-EPS_graph-0.01b
http://search.cpan.org/~aplonis/Chart-EPS_graph-0.01b/
----
Chart-EPS_graph-0.01c
http://search.cpan.org/~aplonis/Chart-EPS_graph-0.01c/
----
Chart-EPS_graph-0.01d
http://search.cpan.org/~aplonis/Chart-EPS_graph-0.01d/
----
Class-DBI-v3.0.15
http://search.cpan.org/~tmtm/Class-DBI-v3.0.15/
Simple Database Abstraction
----
Class-Meta-Declare-0.04
http://search.cpan.org/~ovid/Class-Meta-Declare-0.04/
Deprecated in favor of Class::Meta::Express
----
Device-USB-MissileLauncher-0.01
http://search.cpan.org/~gmccar/Device-USB-MissileLauncher-0.01/
interface to toy USB missile launchers
----
Device-USB-MissileLauncher-0.02
http://search.cpan.org/~gmccar/Device-USB-MissileLauncher-0.02/
interface to toy USB missile launchers
----
Error-0.17003
http://search.cpan.org/~pevans/Error-0.17003/
Error/exception handling in an OO-ish way
----
Etk-Perl-0.04
http://search.cpan.org/~leviathan/Etk-Perl-0.04/
----
Games-Sudoku-SudokuTk-0.04
http://search.cpan.org/~cguine/Games-Sudoku-SudokuTk-0.04/
Perl extension for Sudoku with Tk
----
Getopt-Long-Descriptive-0.06
http://search.cpan.org/~hdp/Getopt-Long-Descriptive-0.06/
Getopt::Long with usage text
----
HTTP-MobileAgent-0.26
http://search.cpan.org/~kurihara/HTTP-MobileAgent-0.26/
HTTP mobile user agent string parser
----
ICS-Simple-0.01
http://search.cpan.org/~wilsond/ICS-Simple-0.01/
Simple interface to CyberSource ICS2
----
ICS-Simple-0.02
http://search.cpan.org/~wilsond/ICS-Simple-0.02/
Simple interface to CyberSource ICS2
----
Module-Depends-Tree-0.01
http://search.cpan.org/~petdance/Module-Depends-Tree-0.01/
A container for functions for the deptree program
----
Module-Depends-Tree-0.02
http://search.cpan.org/~petdance/Module-Depends-Tree-0.02/
A container for functions for the deptree program
----
PDL-2.4.3
http://search.cpan.org/~csoe/PDL-2.4.3/
the Perl Data Language
----
Perl-Critic-0.19
http://search.cpan.org/~thaljef/Perl-Critic-0.19/
Critique Perl source code for best-practices
----
RPC-JSON-0.11
http://search.cpan.org/~jshirley/RPC-JSON-0.11/
JSON-RPC Client Library
----
SQLite-Work-0.08
http://search.cpan.org/~rubykat/SQLite-Work-0.08/
report on and update an SQLite database.
----
Senna-0.50_02
http://search.cpan.org/~dmaki/Senna-0.50_02/
Perl Interface To Senna Fulltext Search Engine
----
Senna-0.50_03
http://search.cpan.org/~dmaki/Senna-0.50_03/
Perl Interface To Senna Fulltext Search Engine
----
String-Object-0.01
http://search.cpan.org/~rhundt/String-Object-0.01/
A String Object
----
Test-Perl-Critic-0.07
http://search.cpan.org/~thaljef/Test-Perl-Critic-0.07/
Use Perl::Critic in test programs
----
Text-NeatTemplate-0.08
http://search.cpan.org/~rubykat/Text-NeatTemplate-0.08/
a fast, middleweight template engine.
----
VMS-Device-0_09
http://search.cpan.org/~cberry/VMS-Device-0_09/
Perl interface to VMS device system calls ($GETDVI and friends)
----
VMS-Queue-0_58
http://search.cpan.org/~cberry/VMS-Queue-0_58/
Perl extension to manage queues, entries, and forms, and retrieve queue, entry, and form information.
----
WWW-WebArchive-0.50
http://search.cpan.org/~spadkins/WWW-WebArchive-0.50/
Retrieve old versions of public web pages from various web archives (i.e. www.archive.org, Internet Archive's Wayback Machine, or Google's page cache)
----
XML-DOM-Lite-0.11
http://search.cpan.org/~rhundt/XML-DOM-Lite-0.11/
Lite Pure Perl XML DOM Parser Kit
----
dvdrip-0.98.0
http://search.cpan.org/~jred/dvdrip-0.98.0/
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Mon, 21 Aug 2006 04:35:30 -0400
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Printing to a file Or STDOUT
Message-Id: <5eydnQjnp9S-7XTZnZ2dnUVZ_oydnZ2d@comcast.com>
I thought this was a FAQ, but I can't find it, which means it either isn't
as obvious as I think or I'm just using the wrong search terms.
I want to be able to print to either STDOUT or to a file, so if I have a
series of print statements like:
print $fh "This is a line of text\n";
I'd like to be able to have $fh be able to refer to STDOUT so a command line
option for my program could specify to either save the output to a file or
print it to the console. I know I can just open the file, but how to I set
$fh equal to the actual STDOUT stream?
Thanks!
Hal
------------------------------
Date: Mon, 21 Aug 2006 10:42:45 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Printing to a file Or STDOUT
Message-Id: <ecbrqb$iuk$1@nntp.fujitsu-siemens.com>
Hal Vaughan wrote:
> I thought this was a FAQ, but I can't find it, which means it either is=
n't
> as obvious as I think or I'm just using the wrong search terms.
>=20
> I want to be able to print to either STDOUT or to a file, so if I have =
a
> series of print statements like:
>=20
> print $fh "This is a line of text\n";
>=20
> I'd like to be able to have $fh be able to refer to STDOUT so a command=
line
> option for my program could specify to either save the output to a file=
or
> print it to the console. I know I can just open the file, but how to I=
set
> $fh equal to the actual STDOUT stream?
my $fh =3D \*STDOUT;
print $fh "Hello, world\n";
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: 21 Aug 2006 10:48:03 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Printing to a file Or STDOUT
Message-Id: <5osie2tcm4p0r5gidhp6uc06357akopif2@4ax.com>
On Mon, 21 Aug 2006 04:35:30 -0400, Hal Vaughan
<hal@thresholddigital.com> wrote:
>print it to the console. I know I can just open the file, but how to I set
>$fh equal to the actual STDOUT stream?
perldoc -q indirectly
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: Mon, 21 Aug 2006 00:43:59 +0200
From: =?ISO-8859-1?Q?J=FCrgen_Herz?= <juergenherz@gmail.com>
Subject: References - problem understanding them
Message-Id: <ecaojc$jvp$1@news1.nefonline.de>
Hi,
currently I'm trying to understand references. I've read perltut.pod and
perlreftut.pod but still don't know why does this works:
my $content = test();
for (keys %{$content})
{ print "$_: ",$content->{$_},"\n" }
sub test
{
my %content = (one => "eins", two => "zwei");
return \%content;
}
I'd expect accessing the hash in main doesn't work because it doesn't
exist anymore outside of test(), just the pointer to that gone hash.
I guess I'm wrong in understanding references as pointers like they are
in C. But what are they then?
Regards,
Jürgen
------------------------------
Date: Mon, 21 Aug 2006 00:04:04 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: References - problem understanding them
Message-Id: <ecapp4$e5f$1@gemini.csx.cam.ac.uk>
Jürgen Herz wrote:
> Hi,
>
> currently I'm trying to understand references. I've read perltut.pod and
> perlreftut.pod but still don't know why does this works:
missing:
use strict;
use warnings;
(though in fact your code is fine w.r.t. both of them)
> my $content = test();
> for (keys %{$content})
> { print "$_: ",$content->{$_},"\n" }
>
> sub test
> {
> my %content = (one => "eins", two => "zwei");
> return \%content;
> }
>
> I'd expect accessing the hash in main doesn't work because it doesn't
> exist anymore outside of test(), just the pointer to that gone hash.
OK. I take it you were expecting this code *not* to work, and are
surprised that it did? That's a change from most questions around here :)
> I guess I'm wrong in understanding references as pointers like they are
> in C. But what are they then?
I don't know the details of how references are implemented in Perl, but
they are more than just a bare pointer (i.e. integer) like that you
would get in C.
The reason that your example works is that Perl is a garbage-collected
language (unlike C), and many garbage-collected languages maintain
counts of references to chunks of memory that are allocated. The memory
is only freed when the reference count goes to zero. Since your sub
returns a reference to the hash created within it, that hash sticks
around so long as the reference exists.
DS
------------------------------
Date: Sun, 20 Aug 2006 23:55:55 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: References - problem understanding them
Message-Id: <fE6Gg.19457$uV.5340@trnddc08>
Jürgen Herz wrote:
> Hi,
>
> currently I'm trying to understand references. I've read perltut.pod
> and perlreftut.pod but still don't know why does this works:
>
> my $content = test();
> for (keys %{$content})
> { print "$_: ",$content->{$_},"\n" }
>
> sub test
> {
> my %content = (one => "eins", two => "zwei");
> return \%content;
> }
>
> I'd expect accessing the hash in main doesn't work because it doesn't
> exist anymore outside of test(), just the pointer to that gone hash.
What is gone after the sub is the _name_ %content. But the object behind
that name still exists. There is still a reference pointing to the object
and therefore the perl garbage collector does not recycle that object yet.
> I guess I'm wrong in understanding references as pointers like they
> are in C. But what are they then?
They are references. And they have very little in common with pointers in C.
Actually they are much easier to understand if you don't have the burden of
previous C knowledge.
jue
------------------------------
Date: 20 Aug 2006 23:59:48 GMT
From: xhoster@gmail.com
Subject: Re: References - problem understanding them
Message-Id: <20060820200034.153$tz@newsreader.com>
Jürgen_Herz <juergenherz@gmail.com> wrote:
> Hi,
>
> currently I'm trying to understand references. I've read perltut.pod and
AFAIK, there is no perltut. Have you read perlref?
> perlreftut.pod but still don't know why does this works:
>
> my $content = test();
> for (keys %{$content})
> { print "$_: ",$content->{$_},"\n" }
>
> sub test
> {
> my %content = (one => "eins", two => "zwei");
> return \%content;
> }
>
> I'd expect accessing the hash in main doesn't work because it doesn't
> exist anymore outside of test(), just the pointer to that gone hash.
Garbage collection is explained in the 2nd paragraph (v.5.8.8) of
the "description" section of perlref.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 20 Aug 2006 17:01:24 -0700
From: "Klaus" <klaus03@gmail.com>
Subject: Re: References - problem understanding them
Message-Id: <1156118484.086646.214570@i42g2000cwa.googlegroups.com>
J=FCrgen Herz wrote:
> Hi,
>
> currently I'm trying to understand references. I've read perltut.pod and
> perlreftut.pod but still don't know why does this works:
>
> my $content =3D test();
> for (keys %{$content})
> { print "$_: ",$content->{$_},"\n" }
>
> sub test
> {
> my %content =3D (one =3D> "eins", two =3D> "zwei");
> return \%content;
> }
>
> I'd expect accessing the hash in main doesn't work because it doesn't
> exist anymore outside of test(), just the pointer to that gone hash.
>
> I guess I'm wrong in understanding references as pointers like they are
> in C. But what are they then?
There is some explanation in perlsub (although it is not obvious to
find)
-------------------------------------------------
"Persistent Private Variables"
Just because a lexical variable is lexically (also called statically)
scoped to its enclosing block, eval, or do FILE, this doesn't mean that
within a function it works like a C static. It normally works more like
a C auto, but with implicit garbage collection.
Unlike local variables in C or C++, Perl's lexical variables don't
necessarily get recycled just because their scope has exited. If
something more permanent is still aware of the lexical, it will stick
around. So long as something else references a lexical, that lexical
won't be freed--which is as it should be. You wouldn't want memory
being free until you were done using it, or kept around once you were
done. Automatic garbage collection takes care of this for you.
[=2E..]
-------------------------------------------------
------------------------------
Date: 20 Aug 2006 19:00:40 -0700
From: "Aaron Sherman" <AaronJSherman@gmail.com>
Subject: Re: References - problem understanding them
Message-Id: <1156125639.953428.186710@74g2000cwt.googlegroups.com>
J=FCrgen Herz wrote:
> I'd expect accessing the hash in main doesn't work because it doesn't
> exist anymore outside of test(), just the pointer to that gone hash.
>
> I guess I'm wrong in understanding references as pointers like they are
> in C. But what are they then?
People will often tell you C pointers and Perl references aren't the
same thing in response to a question like that, but IMHO that's a
terrible thing to tell a C programmer.
In reality they're the same thing, but what you should not do is
confuse lexically scoped variables with stack-allocated variables in C.
You essentially have no access to the stack at all in Perl. The "Perl
stack" is malloced memory, and items allocated on it are freed when
they are no longer referenced. By creating a reference to your
lexically scoped hash, you asked Perl not to release it.
Hope that helps, one C programmer to another.
------------------------------
Date: 21 Aug 2006 05:34:00 GMT
From: John Bokma <john@castleamber.com>
Subject: Reported (was Re: A Editor Feature for Extending)
Message-Id: <Xns98265C37A0B8castleamber@130.133.1.4>
"Xah Lee" <xah@xahlee.org> wrote:
Let's see how fast we can drop you from another hosting provider :-D.
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: 21 Aug 2006 02:16:04 -0700
From: "ska" <skg@mail.inf.fh-brs.de>
Subject: Re: The DEBUG constant?
Message-Id: <1156151764.936296.29040@p79g2000cwp.googlegroups.com>
anno4000@radom.zrz.tu-berlin.de wrote:
> One point about the the approach using constants is that a statement
> qualified by "if DEBUG" will not even be compiled when debugging
> is off. Thus code with "DEBUG => 0" will be the same as if no
> assertions were present at all.
I always wondered:
Can you, for instance, write
assert( condition );
in the code, but let have perl ignore the statement, or let have perl
_not_ evaluate the arguments, unless a $debug (non-constant) is true?
With a preprocessor one could write, e.g.:
#define assert(a) if(debug) _assert(a)
Is something like this possible in plain perl, too?
Bye, ska
------------------------------
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 9631
***************************************