[26579] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8713 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 27 18:05:37 2005

Date: Sun, 27 Nov 2005 15:05:05 -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           Sun, 27 Nov 2005     Volume: 10 Number: 8713

Today's topics:
    Re: hash on private member variable <snort_sam@yahoo.com>
    Re: hash on private member variable <1usa@llenroc.ude.invalid>
    Re: Hash's Regex Transformation with Map robic0
    Re: Help:  String search in Windows 2000 doesn't find t <tadmc@augustmail.com>
    Re: Help:  String search in Windows 2000 doesn't find t <1usa@llenroc.ude.invalid>
    Re: modules, modules, modules <sdn.girths00869@zoemail.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 28 Nov 2005 09:07:45 +1100
From: bsder <snort_sam@yahoo.com>
Subject: Re: hash on private member variable
Message-Id: <438a2e33@news.rivernet.com.au>


A. Sinan Unur wrote:
> sam <samwun@telpacific.com.au> wrote in news:4389ae12$1
> @news.rivernet.com.au:
> 
> 
>>I need to use hash on a private member variable.
>>But I don't  know how to make it happen. Here is the code:
> 
> 
> 1. What does it mean to "use hash on a private member variable"?
> 
Since this is OO style perl, its memeber variable is _map.
I supposed use %_map thruout the entire perl code.
eg.
dbmopen($self->{%_map},$name,0666);

but this give me error.

What is the correct syntax for that?

Thanks
Sam

> 2. The code you posted does not compile.
> 
> Please read the posting guidelines for this group to learn how you can 
> help yourself, and help others help you.
> 
> 
>>sub new {
>>     my $class = shift;
>>     my $self  = { _map => undef };
>>     bless ($self, $class);
>>     return $self;
>>}
> 
> 
> Are you saying you want $self->{_map} to be a reference to an anonymous 
> hash? Then, make it so:
> 
> sub new {
>    my $class = shift;
>    my $self  = { _map => { } };
>    bless ($self, $class);
>    return $self;
> }
> 
> 
>>sub gen_name()
> 
> 
> Why are you using prototypes with method calls?
> 
> 
>>{
>>      my $self = shift;
>>      localtime(time);
> 
> 
> What do you think the line above does?
> 
> 
>>      return rand(time).".pl";
>>}
> 
> 
> If gen_name is invoked more than once in a second, this will return 
> identical filenames ... I have a feeling that will not be good for your 
> program. What are you trying to do?
> 
> 
>>sub create()
>>{
>>         my $self = shift;
>>    my ($name) = "/usr/local/code.dbm";
>>    dbmopen($self->{%_map},$name,0666);
>>    $file_name = $self->gen_name();
>>    $status = "0"; # 0 - not yet execute; 1 - had been executed.
>>    $val = join("\t",$file_name, ,$status);
>>    $map{$file_name} = $val;
> 
> 
> ????
> 
> 
> Sinan


------------------------------

Date: Sun, 27 Nov 2005 22:27:00 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: hash on private member variable
Message-Id: <Xns971BB1870EDDAasu1cornelledu@127.0.0.1>

bsder <snort_sam@yahoo.com> wrote in news:438a2e33@news.rivernet.com.au:

> 
> A. Sinan Unur wrote:
>> sam <samwun@telpacific.com.au> wrote in news:4389ae12$1
>> @news.rivernet.com.au:
>> 
>> 
>>>I need to use hash on a private member variable.
>>>But I don't  know how to make it happen. Here is the code:
>> 
>> 
>> 1. What does it mean to "use hash on a private member variable"?
>> 
> Since this is OO style perl, its memeber variable is _map.
> I supposed use %_map thruout the entire perl code.
> eg.
> dbmopen($self->{%_map},$name,0666);
> 
> but this give me error.
> 
> What is the correct syntax for that?

 ...

>>>sub new {
>>>     my $class = shift;
>>>     my $self  = { _map => undef };
>>>     bless ($self, $class);
>>>     return $self;
>>>}

Well, did you try reading the code?

$self is a reference to an anonymous hash. _map is a key in that hash. 
$self->{_map} is the value, which happens to be another reference to 
another anonymous hash. You want to dereference that reference:

%{ $self->{_map} }

It would be a good idea to read perldoc perlreftut.

Sinan
-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



------------------------------

Date: Sun, 27 Nov 2005 14:45:48 -0800
From: robic0
Subject: Re: Hash's Regex Transformation with Map
Message-Id: <mbdko11283aldqi87h82aauvq8qakjbj5m@4ax.com>

On 26 Nov 2005 19:13:32 GMT, Glenn Jackman <xx087@freenet.carleton.ca>
wrote:

>At 2005-11-26 08:30AM, robic0 <> wrote:
>>  On 26 Nov 2005 12:47:57 GMT, Glenn Jackman <xx087@freenet.carleton.ca>
>>  wrote:
>> >    %nh = map { ($k = $_) =~ s/\[[ATCG]+\]/S/g; $k=> $h->{$_} } (keys %{$h});
>>                         ^^
>>  Yeah but get the can't use global in "my ($k = $_)" since $_ is
>>  global and declared elsewhere (if strict).
>
>You want "(my $k = $_)" then. 

Ahhh so thats it. I found this an odd error since apparently the
"=" sign passed the syntax check before the global.
So the construct "my ($k = $z) =~ s/aaaa/asdf/g" would be ok then?
It also seems odd that multiple single value assignments would cause
a error also:  "my $k=$z=0;" or I remember it gives me errors.



------------------------------

Date: Sun, 27 Nov 2005 14:08:01 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Help:  String search in Windows 2000 doesn't find text in Windows XP: MS Word document
Message-Id: <slrndok4h1.o2e.tadmc@magna.augustmail.com>

Barry Millman <millmanbarry@hotmail.com> wrote:

> OK.  Sorry about the bad code.


Please do not send stealth Cc's. 

That is considered a rude practice, so I'm moving on to 
someone else's post...


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sun, 27 Nov 2005 21:49:18 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Help:  String search in Windows 2000 doesn't find text in Windows XP: MS Word document
Message-Id: <Xns971BAB2245C1asu1cornelledu@127.0.0.1>

Tad McClellan <tadmc@augustmail.com> wrote in 
news:slrndok4h1.o2e.tadmc@magna.augustmail.com:

> Barry Millman <millmanbarry@hotmail.com> wrote:
> 
>> OK.  Sorry about the bad code.
> 
> 
> Please do not send stealth Cc's. 
> 
> That is considered a rude practice, so I'm moving on to 
> someone else's post...

Well, he seems to have found a good match (see elsethread) ;-)

Sinan
-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



------------------------------

Date: Sun, 27 Nov 2005 16:19:09 -0600
From: "Eric J. Roode" <sdn.girths00869@zoemail.net>
Subject: Re: modules, modules, modules
Message-Id: <Xns971BB053AC687sdn.comcast@216.196.97.136>

robic0 wrote in news:thhgo15btusdquaqkbftag0ukvtpcvt1sg@4ax.com:

> Is it just me or do most Perl modules (Cpan) exist
> outside of perl standard distribution? The phrase
> "try this module" casually uttered here. Am I 
> mistaken, so many beta this and beta that listings.
> If I put out a module on CPAN is it a guarantee
> of fittness for any user of it? There is so much
> crap and garbage out there on CPAN it makes my
> head spin (Telnet being one). I've given up
> on anything but in the official distribution.
> Can anyone tell me why I've done that, or am
> I just imagining things?

Perl's standard distribution is large, and The Perl Distribution Gods have 
now chosen to very, very rarely add anything to the distro.  You could 
write The Perfect Module, and it could be in use for years, and it would 
likely not be included in the standard distro.

Use CPAN.  Get familiar with installing non-distro modules.  There are a 
ton of good ones out there.  Yes, there's a ton of crap, too -- Sturgeon's 
Law -- but there's a ton of good stuff.  Don't let "standard distro" be 
your guide.

-- 
Eric
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`


------------------------------

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 8713
***************************************


home help back first fref pref prev next nref lref last post