[28271] in Perl-Users-Digest
Perl-Users Digest, Issue: 9635 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 22 14:05:45 2006
Date: Tue, 22 Aug 2006 11:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 22 Aug 2006 Volume: 10 Number: 9635
Today's topics:
Re: constructing a scalar reference <mumia.w.18.spam+nospam.usenet@earthlink.net>
Re: constructing a scalar reference <mritty@gmail.com>
Help in comparision and writting in Matrix form <vedpsingh@gmail.com>
Re: Help in comparision and writting in Matrix form <rvtol+news@isolution.nl>
Re: Help in comparision and writting in Matrix form anno4000@radom.zrz.tu-berlin.de
Re: how to "anonymize" Perl script before publishing it (Jamie)
Re: How to redefine a sub during testing? <socyl@987jk.com.invalid>
Re: ioctl TIOCSCTTY errno -1 xhoster@gmail.com
Re: OO Perl - How to maintain class state when using in anno4000@radom.zrz.tu-berlin.de
Re: Out Of Memory! - error <zoraxus@gmail.com>
Re: Out Of Memory! - error usenet@DavidFilmer.com
Re: Question about UNIVERSAL <nobull67@gmail.com>
Re: Question about UNIVERSAL <ced@blv-sam-01.ca.boeing.com>
Re: Use of uninitialized value in string eq at ./xml_si <mgarrish@gmail.com>
Re: Use of uninitialized value in string eq at ./xml_si anno4000@radom.zrz.tu-berlin.de
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 22 Aug 2006 17:30:50 GMT
From: "Mumia W." <mumia.w.18.spam+nospam.usenet@earthlink.net>
Subject: Re: constructing a scalar reference
Message-Id: <ebHGg.259$bM.34@newsread4.news.pas.earthlink.net>
On 08/22/2006 04:28 AM, anno4000@radom.zrz.tu-berlin.de wrote:
> Mumia W. <mumia.w.18.spam+nospam.usenet@earthlink.net> wrote in comp.lang.perl.misc:
>> On 08/21/2006 03:43 PM, Dibosia wrote:
>>> $r = {}; # a hashref
>>> $r = []; # an arrayref
>>> $r = ?; # a scalar ref
>>>
>>> What is ? ? [...]
>> $r = \"This is a string.";
>
> Like Heinrich Mislik's "\ undef" approach that results in a reference
> to a read-only value. You can't assign to it and you can't bless it.
> That makes it rather useless for most purposes.
>
> Anno
You're right, it's best to just use an array ref with a single
element.
------------------------------
Date: 22 Aug 2006 10:59:34 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: constructing a scalar reference
Message-Id: <1156269574.802032.23540@74g2000cwt.googlegroups.com>
Mumia W. wrote:
> You're right, it's best to just use an array ref with a single
> element.
Huh? How is using an array ref with a single element an acceptable
solution to a taking a reference to a scalar?
Best is to do what's already been suggested in this thread as the
standard idiom:
my $ref = do { \my $x };
If you don't like the way that looks, you can always cover it with a
layer of indirection, by using Class::Std::Utils:
use Class::Std::Utils
my $ref = anon_scalar();
Paul Lalli
------------------------------
Date: 22 Aug 2006 04:20:31 -0700
From: "Ved" <vedpsingh@gmail.com>
Subject: Help in comparision and writting in Matrix form
Message-Id: <1156245631.480486.153950@i3g2000cwc.googlegroups.com>
Hi all,
I have posted this message in perl.beginers,but didnt get any reply so
am posting here.
I have two set of data which I need to comapre.
The data set is actually a 16x16 Matrix.
Till now I am reading one row at a time by manually changing the
@comp_vhdl0, @comp_vhdl1.... till @comp_vhdl15 and so on.
I want:
1) this to be done using some loop (or some other better method) and
then write it to a file in 16x16 matrix form.
2) After that I want to compare the corresponding values and write the
results in a Marix form( say 1 if match occurs and 0 when mismatch). So
result looks like this
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
..........
..........
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Thanks
Ved
#########################################################################
use strict;
use warnings;
##############This is the data of C based#########
my @VHDL = qw{ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
-2.02344 0.200195 2.41211 0.200195 0.200195 0.200195 0.200195 -1.98242
-2.15234 1.69141 -0.200195 -2.37109 -2.19336 0.200195 -0.200195
-1.99121
-2.00879 -0.200195 2.66309 -0.200195 -0.200195 0.200195 0.200195
1.97363 2.28125 -2.4043 0.200195 2.00977 -2.3916 -0.200195 0.200195
-2.39063
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
0.200195 0.200195 2.77832 2.30469 -2.88184 -0.200195 2.25977 2.15625
-0.200195 -0.200195 2.92676 -0.200195 1.65234 -0.200195 -0.200195
-2.17383
0.200195 1.69824 0.200195 0.200195 0.200195 0.200195 0.200195 2.19727
0.200195 0.200195 0.200195 0.200195 1.19336 0.200195 2.10645 0.200195
-1.32227 1.76563 0.295898 1.73633 0.630859 -0.200195 0.598633 0.263672
0.200195 0.200195 -2.4248 0.325195 0.200195 1.79785 0.844727 -0.331055
0.200195 0.200195 1.60547 1.51758 2.00684 0.200195 1.45215 1.09961
0.200195 0.200195 1.94141 0.200195 1.11621 0.200195 0.200195 0.200195
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
-0.200195 -1.40918 -2.75 0.200195 0.200195 1.92188 -0.200195 -2.81641
0.200195 -0.200195 0.200195 -0.200195 2.36719 -1.53906 -1.98828
-1.80859
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
0.200195 0.200195 1.65234 0.200195 1.38477 0.200195 0.200195 0.200195
0.200195 1.86719 0.833984 1.40723 0.200195 1.77344 1.50098 1.75098
12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12
0.200195 1.0127 1.63477 0.200195 0.200195 1.45801 0.200195
1.05664 0.200195 0.200195 0.200195 0.200195 0.822266 1.41309 1.05762
1.22266
1.88379 -0.420898 0.200195 0.200195 2.06445 0.200195 2.02734 0.200195
0.200195 0.200195 0.200195 -0.326172 1.64258 -0.200195 0.200195
-0.498047
0.200195 0.134766 2.88281 2.35352 0.200195 -0.833984 2.23438 0.200195
0.200195 -1.36328 0.200195 -1.48242 0.200195 0.200195 0.200195
0.0957031
};
my @comp_vhdl0 = (@VHDL[0..15] );
my @comp_vhdl1 = (@VHDL[16..31] );
my @comp_vhdl2 = (@VHDL[32..47] );
my @comp_vhdl3 = (@VHDL[48..63] );
my @comp_vhdl4 = (@VHDL[64..79] );
my @comp_vhdl5 = (@VHDL[80..95] );
my @comp_vhdl6 = (@VHDL[96..111] );
my @comp_vhdl7 = (@VHDL[112..127] );
my @comp_vhdl8 = (@VHDL[128..143] );
my @comp_vhdl9 = (@VHDL[144..159] );
my @comp_vhdl10 = (@VHDL[160..175] );
my @comp_vhdl11 = (@VHDL[176..191] );
my @comp_vhdl12 = (@VHDL[192..207] );
my @comp_vhdl13 = (@VHDL[208..223] );
my @comp_vhdl14 = (@VHDL[224..239] );
my @comp_vhdl15 = (@VHDL[240..255] );
###################################################################################
my @C_based = (
1.138591,1.183786,0.200000,0.200000,1.198204,0.200000,-0.613121,-0.200000,-0.200000,-0.200000,0.200000,-1.189029,-1.203447,1.133348,-0.200000,-0.719774,
-2.023139,0.200000,2.411942,0.200000,0.200000,0.200000,0.200000,-1.981950,-2.151612,1.691232,-0.200000,-2.370753,-2.192801,0.200000,-0.200000,-1.991014,
-2.008857,-0.200000,2.663373,-0.200000,-0.200000,0.200000,0.200000,1.974150,2.281423,-2.405243,0.200000,2.010572,-2.392522,-0.200000,0.200000,-2.390807,
-0.200000,1.527274,-0.734813,0.466545,0.200000,1.456119,-0.444938,-0.200000,0.200000,-0.287225,0.200000,-1.745994,-0.200000,0.200000,-0.200000,1.298406,
0.200000,0.200000,2.777764,2.304864,-2.881801,-0.200000,2.259995,2.155958,-0.200000,-0.200000,2.926670,-0.200000,1.652072,-0.200000,-0.200000,-2.173321,
-0.436979,-0.200000,-0.020078,1.338447,0.346164,-0.110893,0.067381,0.200000,0.566935,-0.845718,-1.240543,0.158196,0.200000,-0.021704,-0.200000,0.010798,
-1.322957,1.766136,0.295488,1.736133,0.630994,-0.200000,0.599127,0.263621,0.200000,0.200000,-2.425058,0.325491,0.200000,1.798003,0.844670,-0.330976,
0.200000,0.200000,1.606202,1.518020,2.007253,-0.200000,1.452384,1.099996,-0.200000,-0.200000,1.941617,0.200000,1.116969,0.200000,-0.200000,1.668842,
0.200000,0.200000,-0.200000,0.200000,0.200000,-0.200000,2.086547,0.200000,-2.706524,-0.200000,0.200000,0.200000,0.200000,-0.200000,2.094820,-0.788359,
-0.200000,-1.408251,-2.749608,0.200000,0.200000,1.921136,-0.200000,-2.815982,0.200000,-0.200000,0.200000,-0.200000,2.366698,-1.538226,-1.987510,-1.808497,
-0.200000,-0.200000,-0.708628,0.131886,0.835285,-0.200000,0.426959,0.342368,0.200000,-0.200000,-0.163459,-0.200000,-0.445128,-0.200000,0.200000,-0.605868,
-0.200000,0.200000,1.652488,0.200000,1.384796,0.200000,0.200000,-0.200000,-0.200000,1.867092,0.834221,1.407785,-0.200000,1.773533,1.501344,1.750544,
0.882552,0.006716,-0.112803,-0.847193,-0.389230,0.046970,-0.887447,-1.867069,-0.665406,-0.200000,-0.200000,-0.200000,0.011611,-0.200000,-0.013422,-0.486606,
-0.200000,1.013352,1.636039,-0.200000,-0.200000,1.458950,0.200000,1.057427,0.200000,-0.200000,0.200000,0.200000,0.823218,1.414111,1.058191,1.223977,
-0.200000,0.437802,-0.111540,-1.372958,-0.200000,-0.069171,-0.200000,-0.074538,0.177407,0.214409,-0.358118,0.542903,-0.200000,0.504278,0.466197,0.257091,
0.200000,-0.229100,1.100052,-1.265568,0.200000,-1.198302,1.748236,0.200000,-0.200000,1.363818,-0.200000,-1.846486,0.200000,0.200000,0.200000,0.378457,
);
my @comp0 = (@C_based[0..15] );
my @comp1 = (@C_based[16..31] );
my @comp2 = (@C_based[32..47] );
my @comp3 = (@C_based[48..63] );
my @comp4 = (@C_based[64..79] );
my @comp5 = (@C_based[80..95] );
my @comp6 = (@C_based[96..111] );
my @comp7 = (@C_based[112..127] );
my @comp8 = (@C_based[128..143] );
my @comp9 = (@C_based[144..159] );
my @comp10 = (@C_based[160..175] );
my @comp11 = (@C_based[176..191] );
my @comp12 = (@C_based[192..207] );
my @comp13 = (@C_based[208..223] );
my @comp14 = (@C_based[224..239] );
my @comp15 = (@C_based[240..255] );
#######################################################
my $format = "The VHDL items are: \n". ("%20f" x @comp_vhdl15 );
printf $format, @comp_vhdl15 ;
my $format = "The C items are: \n". ("%20f" x @comp15 );
printf $format, @comp15 ;
------------------------------
Date: Tue, 22 Aug 2006 14:07:12 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Help in comparision and writting in Matrix form
Message-Id: <ecf38e.1io.1@news.isolution.nl>
Ved schreef:
> I have two set of data which I need to com[pa]re.
> The data set is actually a 16x16 Matrix.
Have you searched on 'matrix' in CPAN?
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 22 Aug 2006 13:53:09 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Help in comparision and writting in Matrix form
Message-Id: <4l0gi5Fe2fulU1@news.dfncis.de>
Ved <vedpsingh@gmail.com> wrote in comp.lang.perl.misc:
> Hi all,
> I have posted this message in perl.beginers,but didnt get any reply so
> am posting here.
>
> I have two set of data which I need to comapre.
> The data set is actually a 16x16 Matrix.
>
> Till now I am reading one row at a time by manually changing the
> @comp_vhdl0, @comp_vhdl1.... till @comp_vhdl15 and so on.
> I want:
> 1) this to be done using some loop (or some other better method) and
> then write it to a file in 16x16 matrix form.
>
> 2) After that I want to compare the corresponding values and write the
> results in a Marix form( say 1 if match occurs and 0 when mismatch). So
> result looks like this
You don't say what "compare" means. I'll suppose a comparison is
"good" (1) if the values are closer together than a threshold (0.001).
Assuming @VHDL and @C_based are set up according to your data,
you could proceed like this:
# make 16 x 16 matrices from the data
my @mat_vhdl = map [splice @VHDL, 0, 16], 0 .. 15;
my @mat_C = map [splice @C_based, 0, 16], 0 .. 15;
# build a matrix of comparison results
my @res;
for my $i ( 0 .. 15 ) {
for my $k ( 0 .. 15 ) {
my $vhdl = $mat_vhdl[ $i]->[ $k];
my $C = $mat_C[ $i]->[ $k];
$res[ $i]->[ $k] = abs( $vhdl - $C) < 0.001 ? 1 : 0;
}
}
# print it
print "@$_\n" for @res;
Anno
------------------------------
Date: Tue, 22 Aug 2006 14:41:38 GMT
From: nospam@geniegate.com (Jamie)
Subject: Re: how to "anonymize" Perl script before publishing it?
Message-Id: <Lc11562547118500x72f404@air.tunestar.net>
In <d00a2f7b43a5c2d3ef124949e2bba582@dizum.com>,
Nomen Nescio <nobody@dizum.com> mentions:
>I want to publish a few of my Perl programs on usenet but I don't want
>it to be obvious who wrote them.
>
>Any tips on "personal style" aspects of Perl that I need to watch out
>for to depersonalize or anonymize them?
Just release it with your name intact. If anyone actually picks on it,
at least you'll know they were interested. :-)
I release some garbage, some good. With perl, I do it because I enjoy it and I
don't really care what others say. In the case of PHP and one or two perl
scripts, it's another story, that is strictly commercial. (business stuff
should have more quality put into it) Smaller web tools and such I put more
quality into.
For some things I do put a lot more effort into, for example anything that goes
on CPAN simply must have test cases and stuff for the CPAN module to work.
I've only done one CPAN tool. CPAN feels more like presenting yourself to a
judge for sentancing as opposed to actually being fun, I can understand
why it's like that, but it's not my idea of "fun" by any means.
My newsreader is an example of "fun garbage" more bugs than you can shake a
stick at. I'm a little embarassed but on the other hand, I do use it all the
time so it is usable, maybe someone else some year will contact me and ask for
the most recent copy I have. (my "home copy" has a lot of bugs fixed but at a
cost of bugs in things I don't use) It's purely for fun, as it should be. No
ones life depends on a newsreader. Fun is the motive, it's a very complex
piece of fun garbage.
You won't be improving anyones life or anything, if those are your reasons..
forget it!
Only reason for releasing anything is because you have a compulsion to do so.
No one cares about the author, no one cares about you. They care about how
whatever-it-is relates to their lives.
Just release it and develop a thick skull. (in the case of the "perl commmunity"
you really /NEED/ a thick skull!) :-)
DO Take this with a grain of salt, doesn't always apply to everything.
Jamie
--
http://www.geniegate.com Custom web programming
guhzo_42@lnubb.pbz (rot13) User Management Solutions
------------------------------
Date: Tue, 22 Aug 2006 12:11:06 +0000 (UTC)
From: kj <socyl@987jk.com.invalid>
Subject: Re: How to redefine a sub during testing?
Message-Id: <eces8q$qmg$1@reader2.panix.com>
In <pan.2006.08.18.13.16.06.654348@PSDT.com> Peter Scott <Peter@PSDT.com> writes:
>On Thu, 17 Aug 2006 15:50:47 +0000, kj wrote:
>> During testing it'd often be *very handy* to be able to redefine
>> a function/subroutine. (E.g., subroutine Foo::A gets a particular
>> value from subroutine Foo::B, which in turn performs some elaborate
>> websearch to get this value; it would simplify the testing of Foo::A
>> tremendously to be able to replace Foo::B with a simple sub that
>> returns a hard-coded value, thus decoupling the testing of Foo::A
>> from the testing of Foo::B.)
>See Test::MockModule. There is also a tutorial article on perl.com.
Thanks for the pointer to the T::MM module; it looks like a useful
one.
But regarding that tutorial, when I searched for Test::MockModule
at perl.com there were no matches. What tutorial were you referring
to?
Thanks again (and thanks to Anno too),
kj
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
------------------------------
Date: 22 Aug 2006 16:40:36 GMT
From: xhoster@gmail.com
Subject: Re: ioctl TIOCSCTTY errno -1
Message-Id: <20060822124056.180$tf@newsreader.com>
Vivek.M <vivekm1234@cyberspace.org> wrote:
> > On 21 Aug 2006 20:24:38 GMT, xhoster@gmail.com wrote:
> >The first thing I'd do to debug it would either be strace -f the perl,
> >or to re-write your example code into the analogous C code, which
> >shouldn't be too hard, and see what happens there.
> Yup, you were right :( :) I did it in C and i get Input/Output error.
> Error no 5 in errno.h. So what do i do now? What the heck is a IO
> error on /dev/tty imply? I've googled and can't seem to figure it out!
I don't even get an IO error with your C code, I get Operation not
permitted error (even in the parent), so presumably this is a highly system
depend thing.
Sorry I can't be more help, but once we isolate the problem to something
not under Perl's control and not reproducible on my system, I lose interest
in pursuing it further...But good luck.
Cheers,
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 22 Aug 2006 10:11:00 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: OO Perl - How to maintain class state when using inherited methods?
Message-Id: <4l03hkFe4qkgU1@news.dfncis.de>
<jeff_nokes@yahoo.com> wrote in comp.lang.perl.misc:
> Hi,
> Here are a couple example class files:
>
> #Collection.pm
>
> package Collection;
>
> our $ClassType = 'Collection_type'; # Class variable
>
> sub new ($;) {
Methods don't honor prototypes. Don't use them with methods, it's only
confusing.
> my($class_name) = @_;
> my $self = {};
> $self->{class_name} = __PACKAGE__;
This is messy. The class your object is blessed into is $class_name.
Smuggling the original class name into the object via __PACKAGE__ won't
(and shouldn't) change that. Finding "Collection" as the alleged
"class_name" of an object that is blessed somewhere else can only
be confusing. Use ref() to find the class of an object.
> $self->{property_1} = 'foo';
> bless($self, $class_name);
> return($self);
> }# end new()
>
>
> sub serializeObject($;) {
> my($self) = @_;
> my $serialized_object = $ClassType . ',' .
> $self->{class_name} . ',' .
> $self->{property_1};
> return($serialized_object);
> }# end serializeObject()
>
>
> sub getClassType($;) {
> return($ClassType);
> }# end getClassType()
>
> 1;
>
> ----------------------------------
>
> #Addresses.pm
>
> package Addresses;
>
> use Collection;
>
> our @ISA = (
> 'Collection',
> );
>
> our $ClassType = 'Addresses_type'; # Class variable.
>
> 1;
>
> -------------------------------
>
> Test script:
>
> perl -e 'use Data::Dumper; use Collection; use Addresses;'\
> -e 'my $obj_addr = Addresses->new();'\
> -e 'print("\n" . Dumper($obj_addr) . "\n" . '\
> -e ' "Serialized Object = " . $obj_addr->serializeObject() .
> "\n" . '\
> -e ' "getClassTtype = " . $obj_addr->getClassType() . "\n"'\
> -e ');'
>
> --------------------------------
>
> Output:
>
> $VAR1 = bless( {
> 'class_name' => 'Collection',
> 'property_1' => 'foo'
> }, 'Addresses' );
>
> Serialized Object = Collection_type,Collection,foo
> getClassTtype = Collection_type
>
> ---------------------------------------
>
> Questions:
>
> (1) Referencing the dumped object in the above output, I can see that
> the namespace of the object is 'Addresses', but all of the internal
> properties are that of the parent class Collection.pm.
The term "namespace" is misleading here. Objects have a *class* which
is a package and hence a name space in some sense. But that doesn't
mean the object will use the package it is blessed into for accessing
package variables. Package variables work exactly as the always work.
What they access is determined at compile time, it doesn't matter
which object uses them.
> Is it that the
> namespace was set to 'Addresses' simply due to the arrow notation
> implicitly invoking the parent class' new() method?
That's what happens. Since the new() method in Collection correctly
blesses an object into the class it is invoked through (Addresses), what
you get it an Addresses object created by the Collection::new method.
That is how it should be.
> And the object
> really has Collection properties because Perl already walked up the ISA
> tree into the Collection namespace?
I don't know what you mean by that.
> (2) Both classes have the same class level variable $ClassType. Even
> though the namespace of the $obj_addr is 'Addresses', when invoking the
> inherited method getClassType(), the output still reflects that of the
> parent class' $ClassType? Why? Again, has Perl already walked up the
> ISA tree to execute this inherited method, and therefore it sees the
> namespace 'Collection' vice 'Addresses'?
When the method getClassType was compiled, the variable
$Collection::ClassType was compiled in. That doesn't change, even if
the method is later invoked through an object of a different class.
> (3) If I want to keep Addresses level stateful data inside the object,
> is the proper way to do so to pass the data into the inherited
> constuctor as arguments?
I don't think so.
Just define a getClassType method in Addresses that accesses the intended
package variable ($Addresses::ClassType) and overrides the one from
Collection.
As far as I can see the values "Collection_type" and "Address_type"
won't change during the program run. You could as well do away with
the package variables and use constant methods:
sub getClassType { 'Collection_type' } # in Collection.pm
sub getClassType { 'Address_type' } # in Address.pm
Anno
------------------------------
Date: 22 Aug 2006 07:52:43 -0700
From: "Zaphod Beeblebrox" <zoraxus@gmail.com>
Subject: Re: Out Of Memory! - error
Message-Id: <1156258363.096885.69020@75g2000cwc.googlegroups.com>
usenet@DavidFilmer.com wrote:
> Zaphod Beeblebrox wrote:
>
> > I am wondering if there is a more efficient way of reading
> > a really large file into an array.
>
> The best way to do that is to not do that. It's rarely necessary or
> advisable to read a file into an array (especially a large file).
>
> Instead of doing something like this:
>
> my @stuff=<MYFILE>;
> foreach my $line_of_stuff( @stuff ) {
> # do stuff with stuff
> }
>
> do something like this:
>
> while ( my $line_of_stuff = <MYFILE> ) {
> # do stuff with stuff
> }
>
> Except use lexical filehandles (with better names) and the
> three-argument form of file open... but that's all another rant (read
> more in 'Perl Best Practices' by Damian Conway)
>
> --
> David Filmer (http://DavidFilmer.com)
HEY!! Thanks so much!
I think you saved me a ton on money on asprin!!
That did the trick! Like you stated, why do I/O when you don't have to!
Cheers..
G
------------------------------
Date: 22 Aug 2006 10:59:00 -0700
From: usenet@DavidFilmer.com
Subject: Re: Out Of Memory! - error
Message-Id: <1156269540.468785.28210@m79g2000cwm.googlegroups.com>
Zaphod Beeblebrox wrote:
> I think you saved me a ton on money on asprin!!
I was serious in recommending the book, Perl Best Practices - it should
be the second Perl book that anyone ever buys (I REALLY wish it had
been in print years ago when I was new to Perl). Use your unspent
asprin budget to grab a copy - you won't regret it.
> That did the trick! Like you stated, why do I/O when you don't have to!
You're still doing I/O (well, I at least), but you're only groking one
line at a time. Slurping an entire file into an array is a common
mistake, especially among newer programmers. There are times when you
need to do that, but usually it's not a good idea because you're
usually processing a file one line at a time.
--
David Filmer (http://DavidFilmer.com)
------------------------------
Date: 22 Aug 2006 04:59:16 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Question about UNIVERSAL
Message-Id: <1156247956.404922.15180@b28g2000cwb.googlegroups.com>
Ferry Bolhar wrote:
> does the ISA-mechanism apply to UNIVERSAL as well?
sub AnotherClass::foo { print "Yes!\n"; 1; }
push @UNIVERSAL::ISA, "AnotherClass";
print "No!\n" unless eval { BogusClass->foo };
------------------------------
Date: Tue, 22 Aug 2006 17:09:36 GMT
From: Charles DeRykus <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Question about UNIVERSAL
Message-Id: <J4Et00.Ap@news.boeing.com>
Ferry Bolhar wrote:
> Hi,
>
> while looking at the code of 'Attribute::Handlers' (just for couriosity),
> I encountered this code fragment:
>
> *{"Attribute::Handlers::UNIVERSAL::MODIFY_${_}_ATTRIBUTES"} =
> _gen_handler_AH_ foreach @{$validtype{ANY}};
>
> IIRC, this will create named subroutines "MODIFY_xxx_ATTRIBUTES"
> (where "xxx" is "SCALAR, "ARRAY", "HASH" and "CODE") in package
> "Attribute::Handlers::UNIVERSAL". These wiil be "attribute handlers" for
> the particular value types.
>
> In the next line, I saw this code:
>
> push @UNIVERSAL::ISA, 'Attribute::Handlers::UNIVERSAL'
> unless grep /^Attribute::Handlers::UNIVERSAL$/, @UNIVERSAL::ISA;
>
> This will push class "Attribute::Handlers::UNIVERSAL" (and so the methods
> defined above) into UNIVERSAL's @ISA array.
>
> Until now, I thought that, if Perl cannot find a method, it will look as
> last chance
> in package UNIVERSAL. Therefore, if one writes
>
> package UNIVERSAL;
>
> sub MySub {...};
>
> "MySub" will be used if a method named "MySub" cannot be found in a class
> or all inherited classes.
>
> But I thought there is one and only one class named "UNIVERSAL"! What
> about class "Attribute::Handlers::UNIVERSAL"? Will this be a different
> UNIVERSAL class? Another "last chance" to look up for methods?
No, I think Attribute::Handlers::UNIVERSAL is just a mneumonic class
name holding methods the Attribute::Handlers class wants to push into
the base class UNIVERSAL's @ISA array.
>
> And does the ISA-mechanism apply to UNIVERSAL as well? If one writes
>
> push @UNIVERSAL::ISA, "AnotherClass";
>
> does Perl look in "UNIVERSAL" and then in "AnotherClass" as well as
> last chance? Couldn't cause this cyclic endless lookups?
No, that'd be recursive as you suspect. The base class UNIVERSAL is the
end-of-the-line check within the ancestor lookup cycle. If nothing's
found during this search, the ancestor lookup cycle repeats looking for
an AUTOLOAD method in each class (although perlobj shows a way to short
circuit the secondary AUTOLOAD lookup). See perldoc perlobj.
hth,
--
Charles DeRykus
------------------------------
Date: 22 Aug 2006 03:56:10 -0700
From: "Matt Garrish" <mgarrish@gmail.com>
Subject: Re: Use of uninitialized value in string eq at ./xml_simple line 154.
Message-Id: <1156244170.025859.158080@74g2000cwt.googlegroups.com>
Brett.R.Davis@gmail.com wrote:
[please don't top post]
> Brett.R.Davis@gmail.com wrote:
> > Matt Garrish wrote:
> > > Brett.R.Davis@gmail.com wrote:
> > >
> > > > I can't seem to get rid of this message :
> > > >
> > > > Use of uninitialized value in string eq at ./xml_simple line 154.
> > > >
> > > It means what it says, which is that you're attempting to compare
> > > values using the eq operator and one or both of the scalars is
> > > undefined. That it's reported at the beginning of the block means you
> > > have to figure out which of the comparisons inside has the undefined
> > > value and either give it a default value before using it, or if you
> > > really don't care, turn of the warnings for that block.
> > >
> > thanks - I wouldn't have put this on the board had i not tried that....
> >
> OK - it can be any code inside the "block"
>
> That makes more sense - I kept trying to narrow it down to line 154.
>
> I'll try and let you know.
The quick-and-dirty approach to debugging these kinds of warnings is to
put a print statement right before each of the comparisons. You'll
figure out really quickly that way which value is undefined as it won't
print either.
Matt
------------------------------
Date: 22 Aug 2006 12:14:19 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Use of uninitialized value in string eq at ./xml_simple line 154.
Message-Id: <4l0aorFe1517U1@news.dfncis.de>
Matt Garrish <mgarrish@gmail.com> wrote in comp.lang.perl.misc:
>
> Brett.R.Davis@gmail.com wrote:
>
> [please don't top post]
>
> > Brett.R.Davis@gmail.com wrote:
> > > Matt Garrish wrote:
> > > > Brett.R.Davis@gmail.com wrote:
> > > >
> > > > > I can't seem to get rid of this message :
> > > > >
> > > > > Use of uninitialized value in string eq at ./xml_simple line 154.
> > > > >
> > > > It means what it says, which is that you're attempting to compare
> > > > values using the eq operator and one or both of the scalars is
> > > > undefined. That it's reported at the beginning of the block means you
> > > > have to figure out which of the comparisons inside has the undefined
> > > > value and either give it a default value before using it, or if you
> > > > really don't care, turn of the warnings for that block.
> > > >
> > > thanks - I wouldn't have put this on the board had i not tried that....
> > >
> > OK - it can be any code inside the "block"
> >
> > That makes more sense - I kept trying to narrow it down to line 154.
> >
> > I'll try and let you know.
>
> The quick-and-dirty approach to debugging these kinds of warnings is to
> put a print statement right before each of the comparisons. You'll
> figure out really quickly that way which value is undefined as it won't
> print either.
A long while ago I wrote some code to support this technique. A sub
detect() takes a number of scalar Perl expressions given as strings
and generates code that checks each for definedness and prints a
result. You eval() this code in the context of your program.
Example:
use Detector;
my ( $a, $b, %c, @d);
$b =12;
@d = ( 0) x 10;
eval detect qw( $a $b $c{one} $d[1]);
This will report $a and %c{one} as undefined. Detector.pm contains
package Detector;
use base 'Exporter';
our @EXPORT = qw( detect);
sub detect {
my @exprs = @_;
join ";\n", map check_code( $_), @exprs;
}
sub check_code {
my $expr = shift;
"defined $expr or print q($expr undefined), qq(\\n)"
}
1;
I never use it, the manual method you describe is good enough.
Anno
------------------------------
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 9635
***************************************