[22564] in Perl-Users-Digest
Perl-Users Digest, Issue: 4785 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 30 00:05:57 2003
Date: Sat, 29 Mar 2003 21:05:07 -0800 (PST)
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, 29 Mar 2003 Volume: 10 Number: 4785
Today's topics:
Re: And... <tassilo.parseval@rwth-aachen.de>
Re: CGI.pm or roll-your-own? <grazz@nyc.rr.com>
Re: currency number to text conversion <uri@stemsystems.com>
Re: DBD-ODBC <randy@theoryx5.uwinnipeg.ca>
help understand dereferencing chance@austin.rr.com
Re: help understand dereferencing <jmcada@hotmail.com>
Re: help understand dereferencing <jmcada@hotmail.com>
Re: help understand dereferencing <gb2312@attbi.com>
Re: help understand dereferencing chance@austin.rr.com
Re: help understand dereferencing <jurgenex@hotmail.com>
Re: help understand dereferencing chance@austin.rr.com
Re: Mail::Sender - comma separated email address lists (Douglas Wilson)
Re: Mail::Sender - comma separated email address lists (Douglas Wilson)
Re: Mail::Sender - comma separated email address lists (Douglas Wilson)
Re: Perl and objects <mail@annuna.com>
threads->new from a thread with perl 5.8.0 <brad@langhorst.com>
Re: WWW::Mechanize newbie question <45673&5@yahoo.co.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 Mar 2003 23:26:53 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: And...
Message-Id: <b65a3t$56m$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Tore Aursand:
> On Sat, 29 Mar 2003 06:40:07 -0600, Ami wrote:
>> Excuse me, Mr. Parseval !
>> It was careless.
>> I'd forgot the fact it was crosspost,
>> because it's been long time since my last post.
>> Entschuldigen Sie, Herr Parseval !
>> Es war unaufmerksam von mich.
>> Volkkommen haben ich verlernt,
>> denn seit meiner letzter Post viel Zeit genommen hast.
>
> I'm very sure that Tassilo understands English. If not, why the h*ll
> would he write his own messages in English?
Oh, don't worry. It was probably just meant to be a nice gesture by the
OP which I don't mind at all. Too bad my Japanese has escaped me lately
so I can't get my own back. :-)
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Sun, 30 Mar 2003 04:08:34 GMT
From: Steve Grazzini <grazz@nyc.rr.com>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <65uha.1931$Xf4.699@twister.nyc.rr.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Steve Grazzini wrote:
>> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>>>We concluded that, since the module doesn't take GET requests,
>>>that is a non-issue in this case.
>>
>> You must be mistaken.
>
> Don't think so.
...
> \n in for instance the subject field in a form (at least a form that
> submits using the POST method) ends up in nothing but literally '\n'
> as part of the message subject. The same with %0A etc. But if the
> querystring is parsed, %0A results in a newline, so the request method
> does make a difference. [...]
The only difference I see is between data that the browser URI-escapes
(i.e. what you've typed in an HTML form) and data that it passes along
untouched (what you've typed in the "address" bar).
But that's browser behavior.
We can manufacture an HTTP request with LWP or a text editor and put
absolutely anything in the body. Maybe it's a core file, or maybe it's
urlencoded content with a cunningly placed '%0A'.
Of course you might be prepared to handle the escaped newline, and in
fact you are, but it has nothing to do with POST being safer than GET.
>
> To summarize, there are three reasons why %0A etc. can't hurt:
> - The fact that only POST requests are supported
> - The Mail::Sender feature you mentioned
> - The fact that the module does "s/\s+/ /g;" with the values of
> the header fields
Okay... mea culpa. I missed the whitespace-collapsing, which seems
like a fine way to address the problem.
--
Steve
------------------------------
Date: Sun, 30 Mar 2003 05:01:53 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: currency number to text conversion
Message-Id: <x7k7ehzbuq.fsf@mail.sysarch.com>
>>>>> "J" == Jodyman <Jodyman@hotmail.com> writes:
J> Good Job Michael,
J> Seems to work fine for me.
J> Jody
and you had to quote all 160 lines of code to say that?
please learn to edit quotes.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sat, 29 Mar 2003 17:18:32 -0600
From: "Randy Kobes" <randy@theoryx5.uwinnipeg.ca>
Subject: Re: DBD-ODBC
Message-Id: <bRpha.10194$_g3.29000@news1.mts.net>
"Bigus" <bigus NO @ SPAM creationfactor .net> wrote in
message news:Eh1ha.179$Qt4.21@newsfep4-winn.server.ntli.net...
> I'm on a Win2k box with ActiveState Perl 5.8. I can't find DBD-ODBC
> when I search via PPM.
[ .. ]
We have a copy in our repository at
http://theoryx5.uwinnipeg.ca/ppms/
which you can access by setting the repository within the ppm shell to
http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer58
best regards,
randy kobes
------------------------------
Date: Sun, 30 Mar 2003 00:19:48 GMT
From: chance@austin.rr.com
Subject: help understand dereferencing
Message-Id: <b65dsp$shv$1@localhost.localdomain>
I'm not a total perl newbie, but I'm no expert either. Hoping somebody
can help get me a little closer to expert here.
Usually, if something in Perl isn't doing what I want, I just erase
it, rewrite it differently, and then try to figure out 'empirically'
what was going on. This particular case though seems important enought
that I'd rather really have somebody who understands exactly tell me
what is going on.
My problem is that, the way I read all documentation so far,
dereferencing a reference to a hash in the two ways I've done it here
(in test_sub_1 and test_sub_2) should be equivalent. But they
aren't. Its really bugging me. (Really bad pun intended ..... I think
that'll make perl people like me more):
here is program which I believe succintly demonstrates my problem. I
believe test_sub_1 and test_sub_2 should do the same thing:
---------------------------------------------------------------------------
#!/usr/local/bin/perl
use strict 'refs';
use warnings;
sub test_sub_1( $ );
sub test_sub_2( $ );
my %test_hash;
$test_hash{'test'} = 0;
print "\nbefore test_sub1 test val = ".$test_hash{'test'}."\n";
test_sub_1(\%test_hash);
print "after test_sub1 test val = ".$test_hash{'test'}."\n\n";
$test_hash{'test'} = 0;
print "before test_sub2 test val = ".$test_hash{'test'}."\n";
test_sub_2(\%test_hash);
print "after test_sub2 test val = ".$test_hash{'test'}."\n\n";
sub test_sub_1( $ )
{
my $hash_ref = shift();
my %test_hash = %$hash_ref;
$test_hash{'test'}=1;
print "inside test_sub1 test val = ".$test_hash{'test'}."\n";
}
sub test_sub_2( $ )
{
my $hash_ref = shift();
$hash_ref->{'test'}=1;
print "inside test_sub2 test val = ".$test_hash{'test'}."\n";
}
---------------------------------------------------------------------------
chance@localhost>perl --version
This is perl, v5.6.1 built for i686-linux
[blablabla]
chance@localhost>bug.pl
before test_sub1 test val = 0
inside test_sub1 test val = 1
after test_sub1 test val = 0
before test_sub2 test val = 0
inside test_sub2 test val = 1
after test_sub2 test val = 1
---------------------------------------------------------------------------
So Empirically speaking, it looks to me like dereferencing the hash
ref like this :
my %test_hash = %$hash_ref;
creates a copy of the origincal hash, so any operations I do on this
newly constructed %test_hash aren't going to side effect things the
way I want them too.
But how the f#%#$%k was I supposed to know that? Where is this
behaviour explained? What do I need to understand so that this makes
sense? Is there a whole host of subtly-related problems which I have
so far in perl career only avoided by luck, or is this just a special
case deal, or me not being able to read documentation correctly?
--
I used to think government was a necessary evil.
I'm not so sure about the necessary part anymore.
------------------------------
Date: Sun, 30 Mar 2003 01:59:27 GMT
From: "Joshua McAdams" <jmcada@hotmail.com>
Subject: Re: help understand dereferencing
Message-Id: <3csha.10031$PY.2461047965@newssvr10.news.prodigy.com>
<chance@austin.rr.com> wrote in message
news:b65dsp$shv$1@localhost.localdomain...
> I'm not a total perl newbie, but I'm no expert either. Hoping somebody
> can help get me a little closer to expert here.
>
> Usually, if something in Perl isn't doing what I want, I just erase
> it, rewrite it differently, and then try to figure out 'empirically'
> what was going on. This particular case though seems important enought
> that I'd rather really have somebody who understands exactly tell me
> what is going on.
>
> My problem is that, the way I read all documentation so far,
> dereferencing a reference to a hash in the two ways I've done it here
> (in test_sub_1 and test_sub_2) should be equivalent. But they
> aren't. Its really bugging me. (Really bad pun intended ..... I think
> that'll make perl people like me more):
>
> here is program which I believe succintly demonstrates my problem. I
> believe test_sub_1 and test_sub_2 should do the same thing:
> --------------------------------------------------------------------------
-
> #!/usr/local/bin/perl
>
> use strict 'refs';
> use warnings;
>
> sub test_sub_1( $ );
> sub test_sub_2( $ );
>
> my %test_hash;
>
> $test_hash{'test'} = 0;
> print "\nbefore test_sub1 test val = ".$test_hash{'test'}."\n";
> test_sub_1(\%test_hash);
> print "after test_sub1 test val = ".$test_hash{'test'}."\n\n";
>
> $test_hash{'test'} = 0;
> print "before test_sub2 test val = ".$test_hash{'test'}."\n";
> test_sub_2(\%test_hash);
> print "after test_sub2 test val = ".$test_hash{'test'}."\n\n";
>
> sub test_sub_1( $ )
> {
> my $hash_ref = shift();
> my %test_hash = %$hash_ref;
> $test_hash{'test'}=1;
>
> print "inside test_sub1 test val = ".$test_hash{'test'}."\n";
> }
>
>
> sub test_sub_2( $ )
> {
> my $hash_ref = shift();
>
> $hash_ref->{'test'}=1;
>
> print "inside test_sub2 test val = ".$test_hash{'test'}."\n";
> }
> --------------------------------------------------------------------------
-
> chance@localhost>perl --version
>
> This is perl, v5.6.1 built for i686-linux
> [blablabla]
>
> chance@localhost>bug.pl
>
> before test_sub1 test val = 0
> inside test_sub1 test val = 1
> after test_sub1 test val = 0
>
> before test_sub2 test val = 0
> inside test_sub2 test val = 1
> after test_sub2 test val = 1
>
> --------------------------------------------------------------------------
-
>
> So Empirically speaking, it looks to me like dereferencing the hash
> ref like this :
>
> my %test_hash = %$hash_ref;
>
> creates a copy of the origincal hash, so any operations I do on this
> newly constructed %test_hash aren't going to side effect things the
> way I want them too.
>
> But how the f#%#$%k was I supposed to know that? Where is this
> behaviour explained? What do I need to understand so that this makes
> sense? Is there a whole host of subtly-related problems which I have
> so far in perl career only avoided by luck, or is this just a special
> case deal, or me not being able to read documentation correctly?
> --
> I used to think government was a necessary evil.
> I'm not so sure about the necessary part anymore.
In the sub_1 function, your are getting confused on the line:
my %test_hash = %$hash_ref;
What is happening here is the reference $hash_ref is getting de-referenced
by the % symbol, effectively becoming a regular hash for the expression.
So, instead of holding on to the reference, you are turning the reference
into a hash and then assigning the hash (not the reference) to %test_hash.
This is standard reference functionality... when you ask a hash reference to
be a hash, it will act just like a hash.
I think that the other way of using a hash reference that you are looking
for is:
sub test_sub_1( $ )
{
my $hash_ref = shift();
$$hash_ref{'test'}=1;
print "inside test_sub1 test val = ".$hash_ref{'test'}."\n";
}
Note the double $$. The right-most is the prefix for hash_ref. The
left-most is responsible for dereferencing hash_ref to a scalar, just as you
would do when you assign to a regular hash:
my %h;
$h{'x'}=0;
#--> hope this helps
------------------------------
Date: Sun, 30 Mar 2003 02:02:33 GMT
From: "Joshua McAdams" <jmcada@hotmail.com>
Subject: Re: help understand dereferencing
Message-Id: <Zesha.10032$u61.2461651054@newssvr10.news.prodigy.com>
<chance@austin.rr.com> wrote in message
news:b65dsp$shv$1@localhost.localdomain...
> I'm not a total perl newbie, but I'm no expert either. Hoping somebody
> can help get me a little closer to expert here.
>
> Usually, if something in Perl isn't doing what I want, I just erase
> it, rewrite it differently, and then try to figure out 'empirically'
> what was going on. This particular case though seems important enought
> that I'd rather really have somebody who understands exactly tell me
> what is going on.
>
> My problem is that, the way I read all documentation so far,
> dereferencing a reference to a hash in the two ways I've done it here
> (in test_sub_1 and test_sub_2) should be equivalent. But they
> aren't. Its really bugging me. (Really bad pun intended ..... I think
> that'll make perl people like me more):
>
> here is program which I believe succintly demonstrates my problem. I
> believe test_sub_1 and test_sub_2 should do the same thing:
> --------------------------------------------------------------------------
-
> #!/usr/local/bin/perl
>
> use strict 'refs';
> use warnings;
>
> sub test_sub_1( $ );
> sub test_sub_2( $ );
>
> my %test_hash;
>
> $test_hash{'test'} = 0;
> print "\nbefore test_sub1 test val = ".$test_hash{'test'}."\n";
> test_sub_1(\%test_hash);
> print "after test_sub1 test val = ".$test_hash{'test'}."\n\n";
>
> $test_hash{'test'} = 0;
> print "before test_sub2 test val = ".$test_hash{'test'}."\n";
> test_sub_2(\%test_hash);
> print "after test_sub2 test val = ".$test_hash{'test'}."\n\n";
>
> sub test_sub_1( $ )
> {
> my $hash_ref = shift();
> my %test_hash = %$hash_ref;
> $test_hash{'test'}=1;
>
> print "inside test_sub1 test val = ".$test_hash{'test'}."\n";
> }
>
>
> sub test_sub_2( $ )
> {
> my $hash_ref = shift();
>
> $hash_ref->{'test'}=1;
>
> print "inside test_sub2 test val = ".$test_hash{'test'}."\n";
> }
> --------------------------------------------------------------------------
-
> chance@localhost>perl --version
>
> This is perl, v5.6.1 built for i686-linux
> [blablabla]
>
> chance@localhost>bug.pl
>
> before test_sub1 test val = 0
> inside test_sub1 test val = 1
> after test_sub1 test val = 0
>
> before test_sub2 test val = 0
> inside test_sub2 test val = 1
> after test_sub2 test val = 1
>
> --------------------------------------------------------------------------
-
>
> So Empirically speaking, it looks to me like dereferencing the hash
> ref like this :
>
> my %test_hash = %$hash_ref;
>
> creates a copy of the origincal hash, so any operations I do on this
> newly constructed %test_hash aren't going to side effect things the
> way I want them too.
>
> But how the f#%#$%k was I supposed to know that? Where is this
> behaviour explained? What do I need to understand so that this makes
> sense? Is there a whole host of subtly-related problems which I have
> so far in perl career only avoided by luck, or is this just a special
> case deal, or me not being able to read documentation correctly?
> --
> I used to think government was a necessary evil.
> I'm not so sure about the necessary part anymore.
oops... left off the extra $ in the debugging line
sub test_sub_1( $ )
{
my $hash_ref = shift();
$$hash_ref{'test'}=1;
print "inside test_sub1 test val = ".$$hash_ref{'test'}."\n";
}
------------------------------
Date: Sun, 30 Mar 2003 02:42:54 GMT
From: gb2312 <gb2312@attbi.com>
Subject: Re: help understand dereferencing
Message-Id: <3E8659AE.8090504@attbi.com>
I really think
my %test_hash = %$hash_ref;
should create a new copy, just like
my @test_array = @$array_ref;
or
my $test_scalar = $$test_scalar;
which is quite consistent.
--
Bin
chance@austin.rr.com wrote:
> I'm not a total perl newbie, but I'm no expert either. Hoping somebody
> can help get me a little closer to expert here.
>
> Usually, if something in Perl isn't doing what I want, I just erase
> it, rewrite it differently, and then try to figure out 'empirically'
> what was going on. This particular case though seems important enought
> that I'd rather really have somebody who understands exactly tell me
> what is going on.
>
> My problem is that, the way I read all documentation so far,
> dereferencing a reference to a hash in the two ways I've done it here
> (in test_sub_1 and test_sub_2) should be equivalent. But they
> aren't. Its really bugging me. (Really bad pun intended ..... I think
> that'll make perl people like me more):
>
> here is program which I believe succintly demonstrates my problem. I
> believe test_sub_1 and test_sub_2 should do the same thing:
> ---------------------------------------------------------------------------
> #!/usr/local/bin/perl
>
> use strict 'refs';
> use warnings;
>
> sub test_sub_1( $ );
> sub test_sub_2( $ );
>
> my %test_hash;
>
> $test_hash{'test'} = 0;
> print "\nbefore test_sub1 test val = ".$test_hash{'test'}."\n";
> test_sub_1(\%test_hash);
> print "after test_sub1 test val = ".$test_hash{'test'}."\n\n";
>
> $test_hash{'test'} = 0;
> print "before test_sub2 test val = ".$test_hash{'test'}."\n";
> test_sub_2(\%test_hash);
> print "after test_sub2 test val = ".$test_hash{'test'}."\n\n";
>
> sub test_sub_1( $ )
> {
> my $hash_ref = shift();
> my %test_hash = %$hash_ref;
> $test_hash{'test'}=1;
>
> print "inside test_sub1 test val = ".$test_hash{'test'}."\n";
> }
>
>
> sub test_sub_2( $ )
> {
> my $hash_ref = shift();
>
> $hash_ref->{'test'}=1;
>
> print "inside test_sub2 test val = ".$test_hash{'test'}."\n";
> }
> ---------------------------------------------------------------------------
> chance@localhost>perl --version
>
> This is perl, v5.6.1 built for i686-linux
> [blablabla]
>
> chance@localhost>bug.pl
>
> before test_sub1 test val = 0
> inside test_sub1 test val = 1
> after test_sub1 test val = 0
>
> before test_sub2 test val = 0
> inside test_sub2 test val = 1
> after test_sub2 test val = 1
>
> ---------------------------------------------------------------------------
>
> So Empirically speaking, it looks to me like dereferencing the hash
> ref like this :
>
> my %test_hash = %$hash_ref;
>
> creates a copy of the origincal hash, so any operations I do on this
> newly constructed %test_hash aren't going to side effect things the
> way I want them too.
>
> But how the f#%#$%k was I supposed to know that? Where is this
> behaviour explained? What do I need to understand so that this makes
> sense? Is there a whole host of subtly-related problems which I have
> so far in perl career only avoided by luck, or is this just a special
> case deal, or me not being able to read documentation correctly?
------------------------------
Date: Sun, 30 Mar 2003 03:24:43 GMT
From: chance@austin.rr.com
Subject: Re: help understand dereferencing
Message-Id: <b65onk$svv$1@localhost.localdomain>
Joshua McAdams <jmcada@hotmail.com> wrote:
> <chance@austin.rr.com> wrote in message
> news:b65dsp$shv$1@localhost.localdomain...
> In the sub_1 function, your are getting confused on the line:
> my %test_hash = %$hash_ref;
Total agreement there! However, I think my test case, as precise as I
tried to be, may have had enough problems to mask my real question.
Let me try again. If I dereference $hash_ref with
my %test_hash = %$hash_ref;
and I get a hash, which hash is it? I was expecting it to be the exact
same hash, in every way I can think of, (including ability to side
effect it in the subroutine) that was used to create the original
external-to-the-subroutine reference with.
-------------------------------------------------------------------------------
#!/usr/local/bin/perl
use strict;
use warnings;
sub test_sub_1( $ );
sub test_sub_2( $ );
my %test_hash_global;
$test_hash_global{'test'} = 'global';
print "\nbefore test_sub1 test val = ".$test_hash_global{'test'}."\n";
test_sub_1(\%test_hash_global);
print "after test_sub1 test val = ".$test_hash_global{'test'}."\n\n";
$test_hash_global{'test'} = 'global';
print "before test_sub2 test val = ".$test_hash_global{'test'}."\n";
test_sub_2(\%test_hash_global);
print "after test_sub2 test val = ".$test_hash_global{'test'}."\n\n";
sub test_sub_1( $ )
{
my $hash_ref = shift();
my %test_hash = %$hash_ref;
# some form of test_hash_global is getting in here OK
print "inside test_sub1 test val (before attempting side affect) = ".$test_hash{'test'}."\n";
$test_hash{'test'}='sub value';
# just can't side effect the real thing in the outside world
print "inside test_sub1 test val = ".$test_hash{'test'}."\n";
}
sub test_sub_2( $ )
{
my $hash_ref = shift();
$hash_ref->{'test'}='sub value';
print "inside test_sub2 test val = ".$hash_ref->{'test'}."\n";
}
-------------------------------------------------------------------------------
chance@localhost>bug.pl
before test_sub1 test val = global
inside test_sub1 test val (before attempting side affect) = global
inside test_sub1 test val = sub value
after test_sub1 test val = global
before test_sub2 test val = global
inside test_sub2 test val = sub value
after test_sub2 test val = sub value
-------------------------------------------------------------------------------
Do I just not understand how Perl references work?
I'm thinking of them pretty much as plain old pointers.
So I'm expecting test_sub_1 to behave like this C++ pseudo code.
(assume hash class exists, and 'does the right thing', where part
of 'the right thing' means '=' isn't overloaded).
void test_sub_1(hash *x)
{
hash y = *x;
y.set_pair('test','sub value'); /* equivalent to
x->set_pair('test','sub value') */
}
where it appears to me I'm getting something more like this:
void test_sub_1(hash *x)
{
hash y = *x;
y = y.copy(y); /* my best theory at this point in time,
tied with theory of human brain lock (mine) */
y.set_pair('test','sub value'); /* if all we want to do is side effect
whats pointed at by x, this is useless */
}
--
I used to think government was a necessary evil.
I'm not so sure about the necessary part anymore.
------------------------------
Date: Sun, 30 Mar 2003 04:09:45 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: help understand dereferencing
Message-Id: <d6uha.6700$pW1.544@nwrddc01.gnilink.net>
chance@austin.rr.com wrote:
> Joshua McAdams <jmcada@hotmail.com> wrote:
>> <chance@austin.rr.com> wrote in message
>> news:b65dsp$shv$1@localhost.localdomain...
>
>
>> In the sub_1 function, your are getting confused on the line:
>> my %test_hash = %$hash_ref;
>
> Total agreement there! However, I think my test case, as precise as I
> tried to be, may have had enough problems to mask my real question.
>
> Let me try again. If I dereference $hash_ref with
>
> my %test_hash = %$hash_ref;
>
> and I get a hash, which hash is it? I was expecting it to be the exact
> same hash, in every way I can think of, (including ability to side
> effect it in the subroutine) that was used to create the original
> external-to-the-subroutine reference with.
Your problem is not with references, but with assignments.
$hash_ref is a reference to a hash.
That means %$hash_ref is a hash. And it behaves in any way just as if you
would have defined it like e.g. %myhash = (foo => 'foo item', bar => 'bar
item');
Now, if you assign %test_hash = %myhash, what would you expect to happen
when you modify an element in %test_hash? Will it change %myhash, too? No,
it doesn't, because %test_hash is a _copy_ of %myhash, not a reference to
%myhash.
And exactly the same happens to your %$hash_ref. In %test_hash = %$hash_ref
you are creating an identical _copy_ of the hash %$hash_ref. And later on
you are modifying this copy, not the original hash.
If you want to have a second handle to the original hash, then you have to
create a second reference:
$test_hash_ref = $hash_ref;
jue
------------------------------
Date: Sun, 30 Mar 2003 04:27:22 GMT
From: chance@austin.rr.com
Subject: Re: help understand dereferencing
Message-Id: <b65sd5$t1d$1@localhost.localdomain>
In comp.lang.perl.misc gb2312 <gb2312@attbi.com> wrote:
> I really think
> my %test_hash = %$hash_ref;
> should create a new copy, just like
> my @test_array = @$array_ref;
> or
> my $test_scalar = $$test_scalar;
> which is quite consistent.
Ahhhh .... I didn't think it should (in the documentation sense, not
the philosophical sense), but I thought it was. Hence my consternation.
What should I read that I haven't read (or understood?)
I wasn't aware that 'my @test_array = @$array_ref; ' created an array copy either.
You know how do get back the 'real thing' and not a copy? Is that just
no possible?
Chance
--
I used to think government was a necessary evil.
I'm not so sure about the necessary part anymore.
------------------------------
Date: Sun, 30 Mar 2003 01:50:01 GMT
From: dwilson@gtemail.net (Douglas Wilson)
Subject: Re: Mail::Sender - comma separated email address lists
Message-Id: <3e864bb1.3049914@news.west.cox.net>
On 26 Mar 2003 07:59:38 -0800, David.Hiskiyahu@brinksinc.com (David Hiskiyahu)
wrote:
>use Mail::Sender;
>
> eval {
> (new Mail::Sender)
> ->MailMsg({smtp => $server,
> from => $sendFrom,
> replyto => $replyTo,
> to => $sendTo,
> cc => $sendCC,
> subject => $sendSubj,
> msg => $sendMsg })
> } or die "Mail::Sender error!\n";
You should know that Mail::Sender by default does not die on errors, it
returns a negative integer error code, so there is no point in eval'ing this.
The correct default error checking method here is:
unless (ref ( ...insert mail sender methods here...) {
# There was an error
}
Sorry, this doesn't help you with your original problem, I don't see any
thing wrong with your 'To' list.
Cheers,
-Douglas Wilson
------------------------------
Date: Sun, 30 Mar 2003 01:54:33 GMT
From: dwilson@gtemail.net (Douglas Wilson)
Subject: Re: Mail::Sender - comma separated email address lists
Message-Id: <3e864d7b.3508048@news.west.cox.net>
On Thu, 27 Mar 2003 02:03:30 GMT, Martien Verbruggen <mgjv@tradingpost.com.au>
wrote:
>The documentation says "This parameter may be either a comma separated
>list of email addresses or a reference to a list of addresses." You're
>passing it two addresses separated by a comma _and_ a space. Either
The code splits addresses on a comma followed by any number of spaces, so
there's nothing wrong there.
Cheers,
Douglas Wilson
------------------------------
Date: Sun, 30 Mar 2003 01:59:02 GMT
From: dwilson@gtemail.net (Douglas Wilson)
Subject: Re: Mail::Sender - comma separated email address lists
Message-Id: <3e864e76.3758930@news.west.cox.net>
On 26 Mar 2003 18:36:23 +0000, Brian McCauley <nobull@mail.com> wrote:
>David.Hiskiyahu@brinksinc.com (David Hiskiyahu) writes:
>If you look at the source for Mail::Sender then you'll see that if any
>of the addresses in the To, CC or BCC generate errors it always
>generates the same error listing the whole 'To' field.
>
>My advise, ditch this module, there are much better modules to send
>mail on CPAN.
I've found Mail::Sender to be a reliable and simple to use module for
sending email with attachments. It's also stand-alone (requires no
other modules and has no dependencies except an available
SMTP server), and so is easy to install and use.
Cheers,
Douglas Wilson
------------------------------
Date: Sat, 29 Mar 2003 20:28:09 -0600
From: Joe Creaney <mail@annuna.com>
Subject: Re: Perl and objects
Message-Id: <3E865639.8010901@annuna.com>
I realy want to thank you for the advice I find objects in perl very
confusing. My first expierence with objects was in a C++ book. I would
rather learn objects in perl rather than trying to re-learn programming
in C++.
Tell you what, this is exactly what I have been looking for.
Tore Aursand wrote:
> On Sat, 29 Mar 2003 12:58:32 -0600, Joe Creaney wrote:
>
>>I have been looking a simple object in the programming perl book.
>
>
> After looking at your code, please have a look at:
>
> 'perldoc -f perltoot'
>
>
>>#!/user/bin.perl
>
>
> Really?
>
>
>>use strict;
>
>
> My "standard" way of creating a class is something (...) like this;
>
> package Player;
> use strict;
> use warnings;
>
> sub new {
> my $proto = shift;
> my $class = ref( $proto ) || $proto;
>
> ## Initialise the class with default values my $self = {
> 'name' => '',
> 'x' => 0,
> 'y' => 0,
> }
> bless( $self, $class );
>
> return $self;
> }
>
> 1;
>
> Now this class can be used in my script;
>
> #!/usr/bin/perl
> #
> use strict;
> use warnings;
>
> use Player;
>
> my $Player = Player->new();
> $Player->{'name'} = 'Michael Owen';
> $Player->{'x'} = 235;
> $Player->{'y'} = 678;
>
> print 'Finished populating ' . $Player->{'name'} . "\n";
>
> Totally untested.
>
>
------------------------------
Date: Sun, 30 Mar 2003 03:00:27 GMT
From: Brad Langhorst <brad@langhorst.com>
Subject: threads->new from a thread with perl 5.8.0
Message-Id: <f5tha.2078$lZ2.199787@newsread1.prod.itd.earthlink.net>
I'm seeing unusual problems when i try to start a new thread from a
previously created thread.
I've written a INET socket program to respond to incoming messages with new
messages sent out on a different socket.
I start a new thread for every incoming request .
When I don't need to spawn new threads the program works reliably.
However, some incoming requests have to create multiple responses so I'm
creating new threads...
I get seg faults when that happens
./agent.pl
Segmentation fault
./agent.pl
Segmentation fault
here's the code that creates the inner threads:
Is there something wrong with this?
I was surprised to find that I could not return multiple values from a join
- thus the array_ref and splice
foreach $subtask (@$ra_tasks) {
log_msg("Trying to schedule $subtask asyncronously\n",10);
#thread so these can occur simultaneously
$thr = threads->new(\&schedule_task,
$subtask,
$earliest_start,
$bid_by,
$req_id);
log_msg("adding thread $thr to list of workers\n", 12);
push @workers, $thr;
}
#now gather the results from the workers
foreach $thr (@workers) {
eval {
$ra_ret = $thr->join();
};
if ($@) {
die("subcontracing failed: $@\n");
} else {
($start_time,$end_time, $ra_bids) = splice(@$ra_ret,0,3);
push @subtasks, {'first_start' => $start_time,
'last_end' => $end_time,
'bids' => $ra_bids};
}
}
------------------------------
Date: Sat, 29 Mar 2003 23:56:40 -0500
From: L D Jones <45673&5@yahoo.co.uk>
Subject: Re: WWW::Mechanize newbie question
Message-Id: <3E867908.93EE73AE@yahoo.co.uk>
Kelly Greer wrote:
>
> Thanks L D and Michael,
> Great! I just got this to work. Yesterday, was my first day really working
> with Perl. I'm not doing to bad. lol
>
> Can you suggest a good sniffer program that I can use to see(sniff) what my
> browser is sending to sites?
www.ethereal.com
btw, the group comp.lang.perl no longer exists
------------------------------
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.
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 4785
***************************************