[28369] in Perl-Users-Digest
Perl-Users Digest, Issue: 9733 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 16 14:05:54 2006
Date: Sat, 16 Sep 2006 11: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 Sat, 16 Sep 2006 Volume: 10 Number: 9733
Today's topics:
Complex extensions in C arne.muller@gmail.com
Re: Complex extensions in C anno4000@radom.zrz.tu-berlin.de
Re: deleteing records from DB_File doesnt decrease file paddy3118@netscape.net
Re: deleteing records from DB_File doesnt decrease file <botfood@yahoo.com>
Did not find leading dereferencer, detected at offset sfelkes@hotmail.com
Did not find leading dereferencer, detected at offset sfelkes@hotmail.com
Re: Did not find leading dereferencer, detected at offs <thepoet_nospam@arcor.de>
Re: Did not find leading dereferencer, detected at offs <benmorrow@tiscali.co.uk>
Re: Did not find leading dereferencer sfelkes@hotmail.com
Re: Did not find leading dereferencer <mumia.w.18.spam+nospam.usenet@earthlink.net>
Re: Did not find leading dereferencer <tadmc@augustmail.com>
Error message into scallar <peretz.eyal@gmail.com>
Re: Error message into scallar <someone@example.com>
Re: Learning perl - for experienced programmers cartercc@gmail.com
Re: Learning perl - for experienced programmers <sherm@Sherm-Pendleys-Computer.local>
Re: Learning perl - for experienced programmers <john@castleamber.com>
Re: Learning perl - for experienced programmers <john@castleamber.com>
Re: Learning perl - for experienced programmers <mgarrish@gmail.com>
Re: Modification of a read-only value attempted - why? <pcunix@gmail.com>
Re: Modification of a read-only value attempted - why? anno4000@radom.zrz.tu-berlin.de
Re: Modification of a read-only value attempted - why? <pcunix@gmail.com>
Perl compiler <bill@ts1000.us>
Re: Perl compiler <blkimelman AT comcast.net>
Re: Perl compiler <klaus03@gmail.com>
Re: Sum the middle column for a given unique volser. <tadmc@augustmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Sep 2006 07:32:26 -0700
From: arne.muller@gmail.com
Subject: Complex extensions in C
Message-Id: <1158417146.283745.287940@m7g2000cwm.googlegroups.com>
Hello,
I'm looking for some resources (books, web-sites, docs ...) on how to
write complex perl extensions in C. I've read the perlxstut, but still
don't understand how to convert complex types.
Specificly, my C-routine needs a pointer to a structure, some members
of this structure are pointers to type double arrays. On the perl side
this structure is an object. The return value of the C function is a
different type of structure, but again containing pointers to array (on
the perl side this is an object).
Maybe you can point out some places on the web or news grou articles (I
didn't find much!).
greetings,
Arne
------------------------------
Date: 16 Sep 2006 16:33:32 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Complex extensions in C
Message-Id: <4n2nasF8fk3oU1@news.dfncis.de>
<arne.muller@gmail.com> wrote in comp.lang.perl.misc:
> Hello,
>
> I'm looking for some resources (books, web-sites, docs ...) on how to
> write complex perl extensions in C. I've read the perlxstut, but still
> don't understand how to convert complex types.
>
> Specificly, my C-routine needs a pointer to a structure, some members
> of this structure are pointers to type double arrays. On the perl side
> this structure is an object. The return value of the C function is a
> different type of structure, but again containing pointers to array (on
> the perl side this is an object).
So you want to translate Perl objects (which presumably contain lists of
numbers) into C structs for consumption by XS routines. The basic
method is to use pack() to build the struct in a string. You pass the
string to the XS routine as such and cast it to a (pointer to) the type
of struct you have built. If you have got it right (which will be
non-trivial), you'll find a workable struct in your XS program.
You'll have to use the cumbersome "p" template to create pointers
from one part of the string to another.
Anno
> Maybe you can point out some places on the web or news grou articles (I
> didn't find much!).
>
> greetings,
>
> Arne
>
------------------------------
Date: 16 Sep 2006 01:18:38 -0700
From: paddy3118@netscape.net
Subject: Re: deleteing records from DB_File doesnt decrease file size?
Message-Id: <1158394718.766689.300880@i42g2000cwa.googlegroups.com>
botfood wrote:
> I am working on a DB cleanup tool that purges records from a tie()ed
> file created with DB_File. I have a first pass done on the tool, and
> seems to be functioning. On a test DB it correctly reports that it
> found about 2500 'old' records according to my criteria,and deleted
> them...
>
> problem is that the file itself, which was about 10.3MB for 14k
> records, did not change size after 2500 records were deleted. I sort of
> expected some reduction in file size?!
>
> Is there some kind of 'compact' or cleanup utility that I need to run
> on the database to squeeze out the empty holes or something?
>
>
> snippets shown... not working code
> =======
> ....
> use DB_File;
> tie ( %tempHash , 'DB_File' , "${cfgRelPath_cgi2DB}/${dbfile}" ) ;
>
>
> then later in a loop I delete a specific record with something like
> this
>
> delete($tempHash{$tempKey}) ;
>
> =================
Sometimes the DB optimisations means that record 'deletions' only mean
that the record is marked as unused. This is rather like in some file
systems, when you delete a file, although the file is nolonger listed
in the directory, other programs that look at the underlying disk
structure may well be able to pick up data that was in the deleted
file.
One way to recover the space may be to just copy active records to
another DB file, double check the copy, then delete the original. (But
not if the DB can be accessed concurrently etc).
- Paddy.
------------------------------
Date: 16 Sep 2006 06:53:36 -0700
From: "botfood" <botfood@yahoo.com>
Subject: Re: deleteing records from DB_File doesnt decrease file size?
Message-Id: <1158414816.725207.105390@d34g2000cwd.googlegroups.com>
paddy3118@netscape.net wrote:
> One way to recover the space may be to just copy active records to
> another DB file, double check the copy, then delete the original. (But
> not if the DB can be accessed concurrently etc).
> ----------------
seems to work!
I changed my utility to write the 'keepers' to a new DB, and the 'old'
records to another; then deleted the orginal, renamed the purge one and
archived the old record db. This procedure DID result in a smaller file
when I was done.
thanks.
The REASON this was required hasnt gone away, and I'm not quite sure
what to do about it long term. Its not a perl issue, but is a web
server memory issue.... I have a site running on Apache with this
pretty big database, grew to about 20k records with a total file size
that grew to around 12MB. It recently acted very strangely and would
not write any new records. My best guess at this point is that settings
like the Apache::SizeLimit have something to do with it, but it remains
to be seen whether the Host is willing to alter config files for me.
ThePERL part of this is that I'm open to what people may suggest as
ways to reduce the memory used by any single process accessing the DB.
Especially if I have a report that needs to go thru the whole DB, how
can I reduce the hit on the server? Would it work to split out record
contents into a couple different 'tables' and pull them in if required?
I had thought that by tie()ing to a file on disk,I'd avoid eating up
the RAM and process memory except, but I dont really understand memory
and paging and all that.....
comments? ideas?
d
------------------------------
Date: 16 Sep 2006 02:19:44 -0700
From: sfelkes@hotmail.com
Subject: Did not find leading dereferencer, detected at offset
Message-Id: <1158398383.964156.250960@b28g2000cwb.googlegroups.com>
Hi,
I'm getting a very strange error:
Uncaught exception from user code:
Did not find leading dereferencer, detected at offset 8231.
Its very frustrating because it's not relating it to a specific line of
code and I have 8000 lines of code in my Perl module. Often I can use
my Perl module find but then when I put in a simple print statement in
I get the error. Could you tell me what type of things cause this
error?
I used to use prototypes but I took those out. Instead in subroutines I
dereference as @{ $_[0] ) when I'm expecting an array as one of my
arguments and @_ when an array is the only argument. I use my $hash =
$_[i] when a hash is passed as the only or one of the arguments. I
store references to arrays as $array[$i] = \@array.
Any ideas?
Cheers,
Sean
------------------------------
Date: 16 Sep 2006 02:20:43 -0700
From: sfelkes@hotmail.com
Subject: Did not find leading dereferencer, detected at offset
Message-Id: <1158398443.120979.126810@i3g2000cwc.googlegroups.com>
Hi,
I'm getting a very strange error:
Uncaught exception from user code:
Did not find leading dereferencer, detected at offset 8231.
Its very frustrating because it's not relating it to a specific line of
code and I have 8000 lines of code in my Perl module. Often I can use
my Perl module find but then when I put in a simple print statement in
I get the error. Could you tell me what type of things cause this
error?
I used to use prototypes but I took those out. Instead in subroutines I
dereference as @{ $_[0] ) when I'm expecting an array as one of my
arguments and @_ when an array is the only argument. I use my $hash =
$_[i] when a hash is passed as the only or one of the arguments. I
store references to arrays as $array[$i] = \@array.
Any ideas?
Cheers,
Sean
------------------------------
Date: Sat, 16 Sep 2006 13:03:42 +0200
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: Did not find leading dereferencer, detected at offset
Message-Id: <450bda0a$0$18486$9b4e6d93@newsspool3.arcor-online.net>
sfelkes@hotmail.com wrote:
> I'm getting a very strange error:
>
> Uncaught exception from user code:
> Did not find leading dereferencer, detected at offset 8231.
>
> Its very frustrating because it's not relating it to a specific line of
> code and I have 8000 lines of code in my Perl module. Often I can use
> my Perl module find but then when I put in a simple print statement in
> I get the error. Could you tell me what type of things cause this
> error?
AFAIR this should be an error raised by Text::Balanced,
its pod documentation should have further information
(e.g. which function is responsible for this kind of
error).
HTH
-Chris
------------------------------
Date: Sat, 16 Sep 2006 12:39:53 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Did not find leading dereferencer, detected at offset
Message-Id: <9d4tt3-rlt.ln1@osiris.mauzo.dyndns.org>
Quoth sfelkes@hotmail.com:
>
> I'm getting a very strange error:
>
> Uncaught exception from user code:
> Did not find leading dereferencer, detected at offset 8231.
>
> Its very frustrating because it's not relating it to a specific line of
> code and I have 8000 lines of code in my Perl module. Often I can use
> my Perl module find but then when I put in a simple print statement in
> I get the error. Could you tell me what type of things cause this
> error?
As someone else said, this is a Text::Balanced error, so the offset is
into whatever string you where matching against. Something I find useful
in this case is this little module:
package Carp::AllVerb;
use strict;
use warnings;
use Carp qw/verbose/;
$SIG{__DIE__} = sub {
die @_ if $^S or not defined $^S;
Carp::confess @_;
};
$SIG{__WARN__} = sub {
warn @_ if $^S or not defined $^S;
Carp::cluck @_;
};
1;
, which you use like perl -MCarp::AllVerb myscript, and which then
causes any warn or die to produce a full stack trace.
Ben
--
Joy and Woe are woven fine,
A Clothing for the Soul divine William Blake
Under every grief and pine 'Auguries of Innocence'
Runs a joy with silken twine. benmorrow@tiscali.co.uk
------------------------------
Date: 16 Sep 2006 02:24:26 -0700
From: sfelkes@hotmail.com
Subject: Re: Did not find leading dereferencer
Message-Id: <1158398665.937299.17510@k70g2000cwa.googlegroups.com>
Hi,
I'm getting the same error
Uncaught exception from user code:
Did not find leading dereferencer, detected at offset 8231.
Its very frustrating because it's not relating it to a specific line of
code and I have 8000 lines of code in my Perl module. Often I can use
my Perl module find but then when I put in a simple print statement in
I get the error. Could you tell me what type of things cause this
error?
I used to use prototypes but I took those out. Instead in subroutines I
dereference as @{ $_[0] ) when I'm expecting an array as one of my
arguments and @_ when an array is the only argument. I use my $hash =
$_[i] when a hash is passed as the only or one of the arguments. I
store references to arrays as $array[$i] = \@array.
Any ideas?
Cheers,
Sean
Mumia W. wrote:
> On 09/06/2006 09:38 AM, Ronny wrote:
> > I get a weird error message saying
> >
> > "Did not find leading dereferencer, detected at
> > offset 6728syntax error at ... near "mk_remote_filename"
> >
> > The expression in question is this:
> >
> > join(' ', 'rcp', map(mk_remote_filename, @_))
> >
> > where mk_remote_filename is a sub defined earlier, prototyped
> > as
> >
> > sub mk_remote_filename($)
> >
>
> Maybe part of the problem is that you prototype the sub as
> requiring a scalar parameter, but you don't give it any
> parameters in the call.
>
> > Maybe Perl doesn't like the isolated occurence of the bareword
> > mk_remote_filename here (it doesn't look very perlish to me),
> > but when I check the perldoc for the function map, it mentions
> > a very similar construct. From the perldocs:
> >
> > "@chars = map(chr, @nums);
> > translates a list of numbers to the corresponding characters."
> >
>
> Yes, but chr can function without any parameters.
>
> > What am I doing wrong? Of course I could also write
> > (map { mk_remote_filenam $_ } @_)
> > but I wonder why it doesn't work the way I wrote it.
> >
> > Ronald
> >
>
> Try this: map mk_remote_filename($_), @_
>
> Or you could define mk_remote_filename to not have a prototype
> and use your old code.
------------------------------
Date: Sat, 16 Sep 2006 11:03:11 GMT
From: "Mumia W." <mumia.w.18.spam+nospam.usenet@earthlink.net>
Subject: Re: Did not find leading dereferencer
Message-Id: <PRQOg.12330$bM.7708@newsread4.news.pas.earthlink.net>
On 09/16/2006 04:24 AM, sfelkes@hotmail.com wrote:
> Hi,
>
> I'm getting the same error
> [...]
>
> Any ideas?
>
> Cheers,
>
> Sean
>
Hi Sean, I have no ideas. No one seems to know what "Did not
find leading dereferencer" means. It's not in perldiag, and
the string doesn't appear in the Linux perl (5.8.4) binary:
$ strings perl | grep dereferencer
[ empty ]
------------------------------
Date: Sat, 16 Sep 2006 07:12:09 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Did not find leading dereferencer
Message-Id: <slrnegnqgp.c7k.tadmc@magna.augustmail.com>
sfelkes@hotmail.com <sfelkes@hotmail.com> wrote:
> I have 8000 lines of code in my Perl module.
You might consider a refactoring then.
Even heavy-hitters like CGI.pm and DBI.pm aren't that big.
[snip TOFU, please do not top-post!]
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 16 Sep 2006 09:40:04 -0700
From: "EZP" <peretz.eyal@gmail.com>
Subject: Error message into scallar
Message-Id: <1158424804.518746.180020@k70g2000cwa.googlegroups.com>
Hi all,
I'm trying to insert the error message from a command into scallar.
my commant is somthing like this:
$output = `command 2>$error_output`
I dont want to enter the error into a file.
Thanks in advance.
EZP
------------------------------
Date: Sat, 16 Sep 2006 17:15:37 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Error message into scallar
Message-Id: <ZiWOg.15330$bf5.13178@edtnps90>
EZP wrote:
> Hi all,
> I'm trying to insert the error message from a command into scallar.
> my commant is somthing like this:
>
> $output = `command 2>$error_output`
>
> I dont want to enter the error into a file.
perldoc -q stderr
John
--
use Perl;
program
fulfillment
------------------------------
Date: 16 Sep 2006 06:00:16 -0700
From: cartercc@gmail.com
Subject: Re: Learning perl - for experienced programmers
Message-Id: <1158411616.427653.119180@d34g2000cwd.googlegroups.com>
Matt Garrish wrote:
> Might be a little too easy for an experienced programmer. It sounds
> like he'd be better off jumping straight into the documentation, or
> going for the Camel or Cookbook.
(1) The books are cheap. My local bookstore has a pile of the Llama
books (3ed) for under $10.00 (US). (2) They are a pretty easy
introduction for someone who already knows the questions, and is just
looking for the answers. Different people have different learning
styles. I keep a copy of the Camel book by my side when writing code,
and a copy of the other two on my bed side table for light reading
before going to sleep. And after years, I still find that they remind
me of useful things I had forgotten.
> Basic design practices are basic design practices. If you'd like some
> examples of hideous and unmaintainable Java code there's plenty I'm
> sifting through at my current job. A language is only as bad as the
> person writing it.
True, but something about Java lends itself to good engineering, and
something about Perl lends itself to bad engineering. Plus, with Java,
you can easily run javadoc and get something in a standard format.
There's probably something like that for Perl, but it's not a part of
the core language.
> Consider also that to most people the benefit of perl is cpan and the
> active community, and that the modules you're using to make your
> scripts so short are probably many thousands of lines of maintainable
> code (or not, as not everything in cpan smells like roses).
I started off by writing CGI scripts. ColdFusion is a closed,
proprietary language, to which I have a strong opposition on
philosophical grounds. However, if all you're doing is displaying
database content in web pages, ColdFusion beats Perl with one arm and
four fingers tied behind its back.
Don't get me wrong. I like Perl very much. I can't use ColdFusion (or
Java) for what I do with Perl. It's just that Perl isn't the best
solution to every conceivable problem, and you need different tools in
your toolbox to be able to solve different kinds of problems.
CC
------------------------------
Date: Sat, 16 Sep 2006 11:16:48 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: Learning perl - for experienced programmers
Message-Id: <m2irjnx2n3.fsf@Sherm-Pendleys-Computer.local>
Dan Stromberg <strombrg@dcs.nac.uci.edu> writes:
> I know a variety of languages, from assemblers to VHLL's, but I'd like to
> learn at least the fundamentals of perl 5.
>
> I'd like to find a web article, magazine article or brief book that will
> provide a very dense, pithy introduction.
You might have a look at the Camel, aka "Programming Perl".
Or, just open a terminal and run 'perldoc perl'. It's sort of a "table of
contents" for the included Perl documentation. The docs listed there are
intended to be read in order, but nothing's stopping you from skipping down
to whatever level you feel comfortable with.
If you're using ActiveState's Perl for Windows, it installs HTML-formatted
copies of the same docs, and places a shortcut to it on the Start menu.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: 16 Sep 2006 16:26:27 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Learning perl - for experienced programmers
Message-Id: <Xns9840745F4357Bcastleamber@130.133.1.4>
cartercc@gmail.com wrote:
> True, but something about Java lends itself to good engineering, and
> something about Perl lends itself to bad engineering.
It's the person who makes the decision to do it the bad way, not the
language.
> Plus, with Java,
> you can easily run javadoc and get something in a standard format.
> There's probably something like that for Perl, but it's not a part of
> the core language.
AFAIK it is, it's called POD. And AFAIK it was there before Java was born
:-)
> I started off by writing CGI scripts. ColdFusion is a closed,
> proprietary language, to which I have a strong opposition on
> philosophical grounds. However, if all you're doing is displaying
> database content in web pages, ColdFusion beats Perl with one arm and
> four fingers tied behind its back.
I doubt this :-)
> Don't get me wrong. I like Perl very much. I can't use ColdFusion (or
> Java) for what I do with Perl. It's just that Perl isn't the best
> solution to every conceivable problem, and you need different tools in
> your toolbox to be able to solve different kinds of problems.
Yup true.
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: 16 Sep 2006 16:28:10 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Learning perl - for experienced programmers
Message-Id: <Xns984074A94BE00castleamber@130.133.1.4>
Sherm Pendley <sherm@Sherm-Pendleys-Computer.local> wrote:
[ perldoc ]
> If you're using ActiveState's Perl for Windows, it installs
> HTML-formatted copies of the same docs, and places a shortcut to it on
> the Start menu.
And it's also available in CHM format:
http://htmlhelp.berlios.de/books/chm.php (5.8.6)
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: 16 Sep 2006 09:30:17 -0700
From: "Matt Garrish" <mgarrish@gmail.com>
Subject: Re: Learning perl - for experienced programmers
Message-Id: <1158424217.598354.132860@k70g2000cwa.googlegroups.com>
cartercc@gmail.com wrote:
> Matt Garrish wrote:
> > Might be a little too easy for an experienced programmer. It sounds
> > like he'd be better off jumping straight into the documentation, or
> > going for the Camel or Cookbook.
>
> (1) The books are cheap. My local bookstore has a pile of the Llama
> books (3ed) for under $10.00 (US). (2) They are a pretty easy
> introduction for someone who already knows the questions, and is just
> looking for the answers.
But as per the request of "dense and pithy", those two don't spring to
mind. They're more the "ease your way into programming and perl" type
books that, for an experienced programmer, can be tiresome to read
(perhaps not so much the second, but certainly the llama). He seemed
pretty explicit in his question that he's not looking for the gentle
ease-you-way-in approach to perl.
> Different people have different learning
> styles. I keep a copy of the Camel book by my side when writing code,
> and a copy of the other two on my bed side table for light reading
> before going to sleep.
You and I have very different ideas of what constitutes a good light
read before bed, then... : )
>
> > Basic design practices are basic design practices. If you'd like some
> > examples of hideous and unmaintainable Java code there's plenty I'm
> > sifting through at my current job. A language is only as bad as the
> > person writing it.
>
> True, but something about Java lends itself to good engineering, and
> something about Perl lends itself to bad engineering. Plus, with Java,
> you can easily run javadoc and get something in a standard format.
> There's probably something like that for Perl, but it's not a part of
> the core language.
>
You'll have to provide some explicit demonstrations of how Java lends
itself to anything if you want to convince me. I've been around the
block enough times to know there's enormous amounts of garbage Java
code out there, and that it doesn't inspire bad programmers to do
anything more than write bad Java code.
I don't magically change the way I think of coding when I start writing
Java. What I do do is alter the way I code slightly to account for how
that language is structured. Perl's OO design isn't perfect, but it is
good enough that you should be able to do just about anything you need
or would in another language. And to be honest I prefer some of the
flexibility it provides to stricter OO languages.
I'm not trying to convince you that Perl is the best language for every
problem, I'm simply pointing out that your assertion that Perl is only
good for x number of lines is naive. I have two Perl web apps, one that
exceeds 5000 lines of code in total in all the modules and the other
that's probably well over 15000, and both are incredibly easy to
maintain and extend as needed. Lines of code is not something I
consider when choosing Perl over another language (except that I can
usually write a similar application in far less than if I use Java or
C#), nor is maintenance, because if you can't write maintainable code
in one language it's unlikely you can do it in another as the
principles aren't language specific.
Matt
------------------------------
Date: 16 Sep 2006 02:57:03 -0700
From: "Tony Lawrence" <pcunix@gmail.com>
Subject: Re: Modification of a read-only value attempted - why?
Message-Id: <1158400623.283953.308490@i3g2000cwc.googlegroups.com>
anno4000@radom.zrz.tu-berlin.de wrote:
> Tony Lawrence <pcunix@gmail.com> wrote in comp.lang.perl.misc:
> > Can someone explain this to me?
> >
> > (full text at http://aplawrence.com/Unix/perl_readonly.html ,
> > abbreviated version here)
> >
> > Test code:
>
> [snip code that doesn't show the problem]
>
> > foreach ("foo3","ba3") {
> > # doesn't like this
> > $dayval=$_;
> > caroomba($dayval);
> > }
> >
> >
> >
> > sub caroomba {
> > my $p=shift;
> > print "Caroomba called $p\n";
> > open(I,"./t");
> > while (<I>) {
> > # stuff..
> > }
> > close I;
> > }
> >
> >
> > Caroomba called foo3 Modification of a read-only value attempted at
> > ./t.pl line 23, <I> line 23.
> >
> > Why?
> >
> > Something to do with anonymous arrays, but I don't grok it.
>
> Which anonymous array? I don't see any.
>
> The problem is the nesting (through a sub call) of the outer
> for-loop and the inner while-loop. The outer "for" aliases $_
> to the read-only literal "foo3". This alias is still in effect
> inside the sub. The while-loop now tries to use the variable
> $_ as its implicit variable. Since $_ is aliased to a read-only
> value, that fails with the error you see.
>
> Anno
OK, I see it now. If the subroutine is modified to add
print "\$_ is $_\n";
it shows up quickly:
..
Use of uninitialized value in concatenation (.) or string at ./t.pl
line 21.
$_ is
Caroomba called ba2
$_ is foo3
Caroomba called foo3
Modification of a read-only value attempted at ./t.pl line 24.
I never realized that $_ would be passed down to a subroutine.. I
thought the sub would have its own $_.. but there it is.
So.. this isn't considered a bug or flaw in Perl? This is intended
behavior?
------------------------------
Date: 16 Sep 2006 10:26:32 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Modification of a read-only value attempted - why?
Message-Id: <4n21qoF5hdvdU1@news.dfncis.de>
Tony Lawrence <pcunix@gmail.com> wrote in comp.lang.perl.misc:
>
> anno4000@radom.zrz.tu-berlin.de wrote:
> > Tony Lawrence <pcunix@gmail.com> wrote in comp.lang.perl.misc:
> > > Can someone explain this to me?
> > >
> > > (full text at http://aplawrence.com/Unix/perl_readonly.html ,
> > > abbreviated version here)
> > >
> > > Test code:
> >
> > [snip code that doesn't show the problem]
> >
> > > foreach ("foo3","ba3") {
> > > # doesn't like this
> > > $dayval=$_;
> > > caroomba($dayval);
> > > }
> > >
> > >
> > >
> > > sub caroomba {
> > > my $p=shift;
> > > print "Caroomba called $p\n";
> > > open(I,"./t");
> > > while (<I>) {
> > > # stuff..
> > > }
> > > close I;
> > > }
> > >
> > >
> > > Caroomba called foo3 Modification of a read-only value attempted at
> > > ./t.pl line 23, <I> line 23.
> > >
> > > Why?
> > >
> > > Something to do with anonymous arrays, but I don't grok it.
> >
> > Which anonymous array? I don't see any.
> >
> > The problem is the nesting (through a sub call) of the outer
> > for-loop and the inner while-loop. The outer "for" aliases $_
> > to the read-only literal "foo3". This alias is still in effect
> > inside the sub. The while-loop now tries to use the variable
> > $_ as its implicit variable. Since $_ is aliased to a read-only
> > value, that fails with the error you see.
> >
> > Anno
>
> OK, I see it now. If the subroutine is modified to add
>
> print "\$_ is $_\n";
>
> it shows up quickly:
>
> ..
> Use of uninitialized value in concatenation (.) or string at ./t.pl
> line 21.
> $_ is
> Caroomba called ba2
> $_ is foo3
> Caroomba called foo3
> Modification of a read-only value attempted at ./t.pl line 24.
>
> I never realized that $_ would be passed down to a subroutine.. I
> thought the sub would have its own $_.. but there it is.
$_ is a package variable. It is the same whenever you access it.
> So.. this isn't considered a bug or flaw in Perl? This is intended
> behavior?
It's expected behavior.
Anno
------------------------------
Date: 16 Sep 2006 09:19:36 -0700
From: "Tony Lawrence" <pcunix@gmail.com>
Subject: Re: Modification of a read-only value attempted - why?
Message-Id: <1158423576.627818.200140@m73g2000cwd.googlegroups.com>
anno4000@radom.zrz.tu-berlin.de wrote:
> Tony Lawrence <pcunix@gmail.com> wrote in comp.lang.perl.misc:
> >
> > anno4000@radom.zrz.tu-berlin.de wrote:
> > > Tony Lawrence <pcunix@gmail.com> wrote in comp.lang.perl.misc:
> > > > Can someone explain this to me?
> > > >
> > > > (full text at http://aplawrence.com/Unix/perl_readonly.html ,
> > > > abbreviated version here)
> > > >
> > > > Test code:
> > >
> > > [snip code that doesn't show the problem]
> > >
> > > > foreach ("foo3","ba3") {
> > > > # doesn't like this
> > > > $dayval=$_;
> > > > caroomba($dayval);
> > > > }
> > > >
> > > >
> > > >
> > > > sub caroomba {
> > > > my $p=shift;
> > > > print "Caroomba called $p\n";
> > > > open(I,"./t");
> > > > while (<I>) {
> > > > # stuff..
> > > > }
> > > > close I;
> > > > }
> > > >
> > > >
> > > > Caroomba called foo3 Modification of a read-only value attempted at
> > > > ./t.pl line 23, <I> line 23.
> > > >
> > > > Why?
> > > >
> > > > Something to do with anonymous arrays, but I don't grok it.
> > >
> > > Which anonymous array? I don't see any.
> > >
> > > The problem is the nesting (through a sub call) of the outer
> > > for-loop and the inner while-loop. The outer "for" aliases $_
> > > to the read-only literal "foo3". This alias is still in effect
> > > inside the sub. The while-loop now tries to use the variable
> > > $_ as its implicit variable. Since $_ is aliased to a read-only
> > > value, that fails with the error you see.
> > >
> > > Anno
> >
> > OK, I see it now. If the subroutine is modified to add
> >
> > print "\$_ is $_\n";
> >
> > it shows up quickly:
> >
> > ..
> > Use of uninitialized value in concatenation (.) or string at ./t.pl
> > line 21.
> > $_ is
> > Caroomba called ba2
> > $_ is foo3
> > Caroomba called foo3
> > Modification of a read-only value attempted at ./t.pl line 24.
> >
> > I never realized that $_ would be passed down to a subroutine.. I
> > thought the sub would have its own $_.. but there it is.
>
> $_ is a package variable. It is the same whenever you access it.
>
> > So.. this isn't considered a bug or flaw in Perl? This is intended
> > behavior?
>
> It's expected behavior.
>
> Anno
Ayup. I see it now, thanks. The Camel book actually tells you that
the default variable for angle bracket input is the global $_ and not
the local $_ (p.81 of the 3rd edition, otherwise look for the section
on Line Input (Angle) Operator).
I'm sure I read that at least once, but the significance escaped me -
thanks again.
------------------------------
Date: 16 Sep 2006 09:29:17 -0700
From: "Bill H" <bill@ts1000.us>
Subject: Perl compiler
Message-Id: <1158424157.465990.313280@h48g2000cwc.googlegroups.com>
Can anyone recommend a good perl compiler for creating .exe files
running under Dos?
Bill H www.ts1000.us
------------------------------
Date: Sat, 16 Sep 2006 13:39:35 -0400
From: Master Blaster <blkimelman AT comcast.net>
Subject: Re: Perl compiler
Message-Id: <MPG.1f7600dfc1ae64e989681@newsgroups.comcast.net>
While wandering through cyberspace on 16 Sep 2006 09:29:17 -0700, Bill H
said
> Can anyone recommend a good perl compiler for creating .exe files
> running under Dos?
>
> Bill H www.ts1000.us
You might want to consider perl2exe
------------------------------
Date: 16 Sep 2006 11:04:23 -0700
From: "Klaus" <klaus03@gmail.com>
Subject: Re: Perl compiler
Message-Id: <1158429862.960046.180690@i42g2000cwa.googlegroups.com>
Bill H wrote:
> Can anyone recommend a good perl compiler for creating .exe files
> running under Dos?
perldoc -q compile
------------------------------
Date: Sat, 16 Sep 2006 07:23:17 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Sum the middle column for a given unique volser.
Message-Id: <slrnegnr5l.c7k.tadmc@magna.augustmail.com>
Noatec <Noatec@gmail.com> wrote:
[ snip 150 quoted lines. Please learn how to compose a proper followup. ]
> HOLY CRACKERS !!!!!!!
> You really made me angry !!!!
> I thought about what you said; took some time to cool off and I'm fine
> now.
You really should see the Posting Guidelines that are posted
here frequently.
> Honestly, I'll bet you're probably not the prick you come off to be in
> this medium.
Do you want people to help you or to ignore all of your future posts?
Act accordingly.
> I kinda like the tough love thing.
Then you will learn a whole lot about Perl programming here.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 9733
***************************************