[29225] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 469 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 30 09:10:07 2007

Date: Wed, 30 May 2007 06:09: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           Wed, 30 May 2007     Volume: 11 Number: 469

Today's topics:
    Re: Beyond Inside-Out anno4000@radom.zrz.tu-berlin.de
    Re: Beyond Inside-Out <abigail@abigail.be>
    Re: duplicates <mritty@gmail.com>
    Re: encode UTF8 -> MIME QoS@domain.invalid
    Re: get mail by POP3Client? <jck11@msr.pchome.com.tw>
        I need a subdomain service like kickme.to <post.int@gmail.com>
    Re: login example <stoupa@practisoft.cz>
    Re: SendMail.pm: smtp and gmail Davidcollins001@gmail.com
    Re: SendMail.pm: smtp and gmail <jokinentimo@kolumbus.fi.invalid>
    Re: SendMail.pm: smtp and gmail Davidcollins001@gmail.com
    Re: SendMail.pm: smtp and gmail Davidcollins001@gmail.com
    Re: SendMail.pm: smtp and gmail Davidcollins001@gmail.com
    Re: SendMail.pm: smtp and gmail <ts@dionic.net>
    Re: SendMail.pm: smtp and gmail Davidcollins001@gmail.com
    Re: SendMail.pm: smtp and gmail <mgjv@tradingpost.com.au>
    Re: Use different modules based on variable <manojkumargupta@gmail.com>
    Re: What is MAXINT, or when to use bigint? <sisyphus1@nomail.afraid.org>
    Re: What is MAXINT, or when to use bigint? <paduille.4061.mumia.w+nospam@earthlink.net>
    Re: What is MAXINT, or when to use bigint? <joe@inwap.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 30 May 2007 09:37:22 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Beyond Inside-Out
Message-Id: <5c4uuiF2v64cfU1@mid.dfncis.de>

Abigail  <abigail@abigail.be> wrote in comp.lang.perl.misc:
> anno4000@radom.zrz.tu-berlin.de (anno4000@radom.zrz.tu-berlin.de) wrote
> on M September MCMXCIII in <URL:news:5c3amnF2te5gtU1@mid.dfncis.de>:
> //  Dr.Ruud <rvtol+news@isolution.nl> wrote in comp.lang.perl.misc:
> // > anno4000@radom.zrz.tu-berlin.de schreef:
> // > 
> // > > Unlike inside-out classes, Alter-based classes don't need extra
> // > > support for garbage collection and thread cloning.  Like inside-
> // > > out, they do need help in serialization.  The standard modules
> // > > Data::Dumper and Storable don't do anything for them.
> // > 
> // > "not anything" is too little, because both have hooks for integration
> // > with classes.
> //  
> //  Oh yes, but the hooks must be supplied.  If you give an inside-out
> //  object to Data::Dumper, without help it will dump an undefined blessed
> //  scalar: "bless( do{\(my $o = undef)}, 'SomeClass' )".  The same goes
> //  for Alter-based classes.
> //  
> //  A difference is that with inside-out classes, essentially every class
> //  must provide the hooks individually.  Only the class knows which
> //  object fields need to be dumped.  With Alter-based classes, there is
> //  the possibility of general methods to handle dumping, thawing and
> //  freezing, that work with all objects and can be inherited or imported.
> 
> 
> That's not true. You can quite easily write a generic function that
> provides the hook; said function can be exported.
> 
> Just define your attributes as:
> 
>     our @ATTRIBUTES = \my (
>         %attr1,
>         %attr2,
>         ...
>     );
> 
> 
> and your exported hook can access the attributes without any problems.

Aha.  A package variable that gives access to all attribute hashes of
the class.  You might as well use the code slot of *ATTRIBUTES and
make it a method

    sub ATTRIBUTES { \ ( %attr1, %attr2, ...) }

That's good, but it isn't good enough.  You can access the attributes
of the class an object is blessed into, but you don't know about
other classes it might have been initialized to.  That data has to
be dumped as well.  One could try to follow the ISA tree, but that's
not reliable.  Essentially, a general-purpose dumper needs to look
at an object (that's all it has) and know about all data that is
associated with the object.  That is still hard to achieve with
inside-out objects.

> (This remarks is about Inside-Out Objects, I don't know whether that's
>  true for Alter based objects).
> 
> The fact remains is that you need to do some work - but that's to be
> expected. Inside-Out Objects is a technique to provide encapsulation.
> Serialization as done with Data::Dumper and other standard modules use
> by default a technique that only works in the absense of encapsulation.
> 
> With strong encapsulation, serialization is not possible. (Because the
> serialized object is by definition not encapsulated - it can be modified
> and fed back to the object).

That is a very clarifying remark, thanks for that.

Inside-out objects provide encapsulation in a lexical scope, that's
the strongest kind Perl has to offer.  Once the scope is left there's
no going back.  (Except padwalking, there's always an exception.)

Encapsulation with Alter objects is package based.  Only code compiled
in the class package can access the object's attributes in that class,
but any such code can, in the original class code and elsewhere.  That
is a weaker form of encapsulation.

Besides that, since the Alter mechanism is based on magic, it is easy
to breach encapsulation even further, if required.  Just provide the
requisite magic tools in the interface.  An Alter object carries all
its data in all classes in a hidden hash, keyed by class.  Give the
dumper access to that hash and you're done.

Anno


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

Date: 30 May 2007 11:40:04 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Beyond Inside-Out
Message-Id: <slrnf5qoj5.djq.abigail@alexandra.abigail.be>

anno4000@radom.zrz.tu-berlin.de (anno4000@radom.zrz.tu-berlin.de) wrote
on M September MCMXCIII in <URL:news:5c4uuiF2v64cfU1@mid.dfncis.de>:
`'  Abigail  <abigail@abigail.be> wrote in comp.lang.perl.misc:
`' > anno4000@radom.zrz.tu-berlin.de (anno4000@radom.zrz.tu-berlin.de) wrote
`' > on M September MCMXCIII in <URL:news:5c3amnF2te5gtU1@mid.dfncis.de>:
`' > //  Dr.Ruud <rvtol+news@isolution.nl> wrote in comp.lang.perl.misc:
`' > // > anno4000@radom.zrz.tu-berlin.de schreef:
`' > // > 
`' > // > > Unlike inside-out classes, Alter-based classes don't need extra
`' > // > > support for garbage collection and thread cloning.  Like inside-
`' > // > > out, they do need help in serialization.  The standard modules
`' > // > > Data::Dumper and Storable don't do anything for them.
`' > // > 
`' > // > "not anything" is too little, because both have hooks for integration
`' > // > with classes.
`' > //  
`' > //  Oh yes, but the hooks must be supplied.  If you give an inside-out
`' > //  object to Data::Dumper, without help it will dump an undefined blessed
`' > //  scalar: "bless( do{\(my $o = undef)}, 'SomeClass' )".  The same goes
`' > //  for Alter-based classes.
`' > //  
`' > //  A difference is that with inside-out classes, essentially every class
`' > //  must provide the hooks individually.  Only the class knows which
`' > //  object fields need to be dumped.  With Alter-based classes, there is
`' > //  the possibility of general methods to handle dumping, thawing and
`' > //  freezing, that work with all objects and can be inherited or imported.
`' > 
`' > 
`' > That's not true. You can quite easily write a generic function that
`' > provides the hook; said function can be exported.
`' > 
`' > Just define your attributes as:
`' > 
`' >     our @ATTRIBUTES = \my (
`' >         %attr1,
`' >         %attr2,
`' >         ...
`' >     );
`' > 
`' > 
`' > and your exported hook can access the attributes without any problems.
`'  
`'  Aha.  A package variable that gives access to all attribute hashes of
`'  the class.  You might as well use the code slot of *ATTRIBUTES and
`'  make it a method
`'  
`'      sub ATTRIBUTES { \ ( %attr1, %attr2, ...) }
`'  
`'  That's good, but it isn't good enough.

Icky. 

I already use an @ATTRIBUTE array when I write an object, to make
the DESTROY method easier:

    my @ATTRIBUTES = \my (
        %attr1,
        %attr2,
        ...
    )

    sub DESTROY {
        my $key = refaddr (my $self = shift);

        ...

        delete $$_ {$key} for @ATTRIBUTES;
    }


If you use a sub, you end up duplicating the list of attributes in 
your code; or you do something like:

    sub ATTRIBUTES {\@ATTRIBUTES}

but then you might as well use 'our @ATTRIBUTES'.

`'                                          You can access the attributes
`'  of the class an object is blessed into, but you don't know about
`'  other classes it might have been initialized to.  That data has to
`'  be dumped as well.  One could try to follow the ISA tree, but that's
`'  not reliable.

Not reliable as in 'you might want to modify @ISA before you serialize'?
If you modify @ISA at run time, Inside-Out objects will have a problem 
anyway, as that prevents the right DESTROYs to be called if the object goes
out of scope. OTOH, if an object once belonged to class Foo, got data 
associated with it in class Foo, then Foo is removed from @ISA, and then
it is serialized, why would you want to Foo data to be serialized? After
all, it's no longer a Foo.

`'                 Essentially, a general-purpose dumper needs to look
`'  at an object (that's all it has) and know about all data that is
`'  associated with the object.  That is still hard to achieve with
`'  inside-out objects.


That is hard to archieve. Period. A general purpose dumper method cannot
make any assumptions on how a class is implemented - or it wouldn't be
a general purpose dumper. 


`' > (This remarks is about Inside-Out Objects, I don't know whether that's
`' >  true for Alter based objects).
`' > 
`' > The fact remains is that you need to do some work - but that's to be
`' > expected. Inside-Out Objects is a technique to provide encapsulation.
`' > Serialization as done with Data::Dumper and other standard modules use
`' > by default a technique that only works in the absense of encapsulation.
`' > 
`' > With strong encapsulation, serialization is not possible. (Because the
`' > serialized object is by definition not encapsulated - it can be modified
`' > and fed back to the object).
`'  
`'  That is a very clarifying remark, thanks for that.
`'  
`'  Inside-out objects provide encapsulation in a lexical scope, that's
`'  the strongest kind Perl has to offer.  Once the scope is left there's
`'  no going back.  (Except padwalking, there's always an exception.)


Yes. But unlike what many people think, Inside-Out Objects is not about
"preventing other classes to access the data at all costs". It's not about
preventing the data to be accessed - it's about preventing *accidental* 
access. If you put your attributes in 'our' hashes instead of 'my' hashes,
other classes can access the data, but since they have to be specific about
it, there's no accidental access.



Abigail
-- 
$_ = "\x3C\x3C\x45\x4F\x54"; s/<<EOT/<<EOT/e; print;
Just another Perl Hacker
EOT


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

Date: 30 May 2007 03:43:57 -0700
From: Paul Lalli <mritty@gmail.com>
Subject: Re: duplicates
Message-Id: <1180521837.788682.316130@p77g2000hsh.googlegroups.com>

On May 30, 2:55 am, jeevs <jeevan.ing...@gmail.com> wrote:
> On May 29, 11:28 pm, use...@DavidFilmer.com wrote:
> >    my %word;
> >    while (<DATA>) {
> >       chomp;
> >       my ($word1, $word2) = split (/ -> /, $_);
> >       push @{$word{$word1}}, $word2;
> >    }
> >    print($_," -> ",join(" ",@{$word{$_}}),"\n") for keys %word;

> Hi David .. Sorry but i dint follow the syntax you used
>
> like you used
>
> push (@{$hash{$key}}, $value);
>
> How does this work.. I mean i can understand when one uses @{$arr_ref}
> to derefenciate an array ref.
> but what does @{$hash{$key}} stands for...

It's exactly the same thing - @{REF} dereferences the array reference
REF.  In @{$arr_ref}, $arr_ref is the array reference.  In
@{$hash{$key}}, $hash{$key} is the array reference.  That is, the
value of %hash whose key is $key is a reference to an array.  Hashes
and arrays can store *any* kind of scalar variable - integers, floats,
strings, and references too.

> IF you can point me to some
> data or link that will be fine too...

perldoc perllol
perldoc perldsc

Paul Lalli



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

Date: Wed, 30 May 2007 12:07:55 GMT
From: QoS@domain.invalid
Subject: Re: encode UTF8 -> MIME
Message-Id: <vOd7i.1232$WZ6.142@trnddc03>


cc96ai <calvin.chan.cch@gmail.com> wrote in message-id:  <1180483225.415971.63350@k79g2000hse.googlegroups.com>

>
>I got UTF8 value %C3%A9
>how could I encode it become é ?
>
>I try encode_base64 , but no luck
>maybe I miss some, anyone have idea ?

you might like Unicode::Lite



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

Date: Wed, 30 May 2007 20:56:53 +0800
From: "jck11" <jck11@msr.pchome.com.tw>
Subject: Re: get mail by POP3Client?
Message-Id: <f3jsb0$sdq$1@netnews.hinet.net>


"Brian McCauley" <nobull67@gmail.com> 
???????:1180161544.937981.69820@k79g2000hse.googlegroups.com...
> On 26 May, 04:33, "jck11" <j...@msr.pchome.com.tw> wrote:
>
> What do you mean "reserve one copy"?
>
> The POP3 protocol does not delete anything from the server unless you
> do so explicitly.
>

The code below download the mail from the server and delete the mail from 
the server.
I don't know why it delete the mail but it 's ture.
Because why I run the code second tims, I can't get any mail.



use MIME::Parser;
use Mail::POP3Client;
use IO::Socket::SSL;

my $pop3=Mail::POP3Client->new(
  USER=>'xxxxxxxx',
  PASSWORD=>'xxxxxxxx',
  HOST=>'pop.gmail.com',
  PORT=>'995',
  USESSL=>'true',
  DEBUG=>0,
)or die "can't connect the server.\n";

if(($pop3->Count()) < 1){
 print "No messages...\n";
 exit;
}
print $pop3->Count() ." messages found!\n";

for($i=1; $i<=$pop3->Count(); $i++){
  my $msg=$pop3->HeadAndBody($i);
  my $parser=new MIME::Parser;
  $parser->output_dir();
  my $entity=$parser->parse_data($msg);
  my @parts=$entity->parts;
  foreach my $part(@parts){
   my $path=($part->bodyhandle)?$part->bodyhandle->path: undef;
   next unless $path;
   print "path: ", $path, "\n";
  }
}

$pop3->Close();





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

Date: 30 May 2007 00:19:16 -0700
From: stiv <post.int@gmail.com>
Subject: I need a subdomain service like kickme.to
Message-Id: <1180509556.097053.213880@g4g2000hsf.googlegroups.com>

I want to give users of my site the option to register for a subdomain
redirection service. I scanned the Internet for some script, but
didn't really find anything that works. Tried the PHP script from
http://opendomains.vnn.bz/ and many others. So now I want to ask you
if you know of any script in PHP, Perl, Phyton that can accomplish
this task?



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

Date: Wed, 30 May 2007 02:58:21 +0200
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: login example
Message-Id: <f3jqfd$frs$1@ns.felk.cvut.cz>

> I have read numerous books and tried 4 different hosting site such as
> tripod, Bravenet, I use comcast as my isp and comcast doesn't support
> perl or cgi or php.
>
> Is there a link for information on using perl to login with a free or
> no money account where visiotrs to a site can register and access the
> internet without a fee
>
As I know then free hostings not allow to run cgi, php or MySQL. You must 
select some cheap provider (some of them want $10-$15 per month only) or get 
static and public IP address from your ISP and run your own webserver at 
home.
-- 

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail 
from another non-spammer site please.)




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

Date: 30 May 2007 01:40:24 -0700
From: Davidcollins001@gmail.com
Subject: Re: SendMail.pm: smtp and gmail
Message-Id: <1180514424.363425.237230@p77g2000hsh.googlegroups.com>

So, I thought this was going to be quite easy, and it seems like it
should be but I keep getting an error:

$ Could not connect to smtp.googlemail.com


Here is my code:

[CODE]
use Net::SMTP::SSL;

my $smtpserver='smtp.googlemail.com';
my $smtpport=465;

   $smtp = Net::SMTP::SSL->new(Host => $smtpserver,
 			       Port => $smtpport,
 			       debug=> 1) ||
	die "Could not connect to $smtpserver; $!";
[\CODE]

Is there something that I am missing? I dont get any extra info from
including the debug flag.
Thanks



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

Date: Wed, 30 May 2007 11:52:20 +0300
From: Timo Jokinen <jokinentimo@kolumbus.fi.invalid>
Subject: Re: SendMail.pm: smtp and gmail
Message-Id: <dYa7i.171317$rj1.137670@reader1.news.saunalahti.fi>

Davidcollins001@gmail.com wrote:
> So, I thought this was going to be quite easy, and it seems like it
> should be but I keep getting an error:
> 
> $ Could not connect to smtp.googlemail.com
> 
> 
> Here is my code:
> 
> [CODE]
> use Net::SMTP::SSL;
> 
> my $smtpserver='smtp.googlemail.com';
> my $smtpport=465;
> 
>    $smtp = Net::SMTP::SSL->new(Host => $smtpserver,
>  			       Port => $smtpport,
>  			       debug=> 1) ||
> 	die "Could not connect to $smtpserver; $!";
> [\CODE]
> 
> Is there something that I am missing? I dont get any extra info from
> including the debug flag.
> Thanks
> 

Are you sure for port? Default port for SSL is 443

br
-timppa


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

Date: 30 May 2007 02:11:08 -0700
From: Davidcollins001@gmail.com
Subject: Re: SendMail.pm: smtp and gmail
Message-Id: <1180516268.509156.57000@o5g2000hsb.googlegroups.com>

So, I thought this was going to be quite easy, and it seems like it
should be but I keep getting an error:

$ Could not connect to smtp.googlemail.com


Here is my code:

[CODE]
use Net::SMTP::SSL;

my $smtpserver='smtp.googlemail.com';
my $smtpport=465;

   $smtp = Net::SMTP::SSL->new(Host => $smtpserver,
 			       Port => $smtpport,
 			       debug=> 1) ||
	die "Could not connect to $smtpserver; $!";
[\CODE]

Is there something that I am missing? I dont get any extra info from
including the debug flag.
Thanks



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

Date: 30 May 2007 02:14:51 -0700
From: Davidcollins001@gmail.com
Subject: Re: SendMail.pm: smtp and gmail
Message-Id: <1180516491.585717.58970@q69g2000hsb.googlegroups.com>

>
> Are you sure for port? Default port for SSL is 443
>

The gmail page says that their smtp server uses ports 465 or 587,
neither work for me (I tried 443 and it was the same too)
(http://mail.google.com/support/bin/answer.py?answer=13287)



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

Date: 30 May 2007 02:15:08 -0700
From: Davidcollins001@gmail.com
Subject: Re: SendMail.pm: smtp and gmail
Message-Id: <1180516508.516322.212380@w5g2000hsg.googlegroups.com>

>
> Are you sure for port? Default port for SSL is 443
>

The gmail page says that their smtp server uses ports 465 or 587,
neither work for me (I tried 443 and it was the same too)
(http://mail.google.com/support/bin/answer.py?answer=13287)



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

Date: Wed, 30 May 2007 11:42:36 +0100
From: Tim Southerwood <ts@dionic.net>
Subject: Re: SendMail.pm: smtp and gmail
Message-Id: <465d5573$0$640$5a6aecb4@news.aaisp.net.uk>

Davidcollins001@gmail.com wrote:

>>
>> Are you sure for port? Default port for SSL is 443
>>
> 
> The gmail page says that their smtp server uses ports 465 or 587,
> neither work for me (I tried 443 and it was the same too)
> (http://mail.google.com/support/bin/answer.py?answer=13287)

587 usually requires TLSfollowed by an SMTP AUTH, not SSL - and it certainly
accepts an initial connection from telnet.

465 I think is the one that you want for SSL - that is accepting connections
too and it looks like an SSL connect.

Cheers

Tim


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

Date: 30 May 2007 04:24:39 -0700
From: Davidcollins001@gmail.com
Subject: Re: SendMail.pm: smtp and gmail
Message-Id: <1180524278.941483.45880@o5g2000hsb.googlegroups.com>

I just tested sending from gmails smtp server using kmail with the
above settings and it worked fine. I seem to be able to connect using
IO:Socket:SSL, but not using Net::SMTP::SSL



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

Date: Wed, 30 May 2007 22:29:16 +1000
From: Martien verbruggen <mgjv@tradingpost.com.au>
Subject: Re: SendMail.pm: smtp and gmail
Message-Id: <slrnf5qrgs.nu3.mgjv@martien.heliotrope.home>

On Wed, 30 May 2007 11:52:20 +0300,
	Timo Jokinen <jokinentimo@kolumbus.fi.invalid> wrote:
> Davidcollins001@gmail.com wrote:
>> So, I thought this was going to be quite easy, and it seems like it
>> should be but I keep getting an error:
>> 
>> $ Could not connect to smtp.googlemail.com
>> 
>> 
>> Here is my code:
>> 
>> [CODE]
>> use Net::SMTP::SSL;
>> 
>> my $smtpserver='smtp.googlemail.com';
>> my $smtpport=465;
>> 
>>    $smtp = Net::SMTP::SSL->new(Host => $smtpserver,
>>  			       Port => $smtpport,
>>  			       debug=> 1) ||
>> 	die "Could not connect to $smtpserver; $!";
>> [\CODE]
>> 
>> Is there something that I am missing? I dont get any extra info from
>> including the debug flag.
>> Thanks
>> 
>
> Are you sure for port? Default port for SSL is 443

Euhm.. no. 443 is normally used for HTTPS, i.e. HTTP over SSL. SMTP over
SSL is normally done on port 465. smtp.googlemail.com also accepts port
587.

To the OP: You're not using the Net::SMTP(::SSL) API as it is documented
though.  While it might have been a bit more consistent if the hostname
also required a tag; it doesn't. The hostname is the first argument
to new(). So:

my $smtp = Net::SMTP::SSL->new($smtpserver, Port => $smtpport) 
    or die;

should work for you.


Martien
-- 
                        | 
Martien Verbruggen      | I used to have a Heisenbergmobile. Every time
                        | I looked at the speedometer, I got lost.
                        | 


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

Date: 30 May 2007 03:15:20 -0700
From: perlguru <manojkumargupta@gmail.com>
Subject: Re: Use different modules based on variable
Message-Id: <1180520120.625069.204280@q66g2000hsg.googlegroups.com>

On May 29, 5:50 pm, Paul Lalli <mri...@gmail.com> wrote:
> On May 29, 8:07 am, perlguru <manojkumargu...@gmail.com> wrote:
>
>
>
> > This is with respect to a thread "Use different modules based on
> > variable" <http://groups.google.com/group/comp.lang.perl.misc/
> > browse_thread/thread/00b9efe4f4416943?tvc=2> .
>
> > In this I had suggested for making use of 'require', but that
> > suggestion was bounced back very badly.
> > Recently I gave a try, and I see that my suggestion is working :
>
> > I created 1st Module  1.1/Test.pm :-
> > ----------------------------------------------------
> > package Test;
>
> > sub func{
> > print "In 1.1/ \n";
> > return 1;
>
> > }
>
> > 1;
>
> > Created another Module   2.2/Test.pm :-
> > -----------------------------------------------------------
> > package Test;
>
> > sub func{
> > print "In 2.2 \n";
> > return 1;
>
> > }
>
> > 1;
>
> > The Main program :-
> > --------------------------------
> > #!/usr/bin/perl
>
> > $ver=$ARGV[0];
>
> > if ( $ver eq '1.1' ){
> >    require "./1.1/Test.pm";
> >    Test::func();
> >    require "./2.2/Test.pm";
> >    Test::func();}else{
>
> >    require "./2.2/Test.pm";
> >    Test::func();
> >    require "./1.1/Test.pm";
> >    Test::func();
>
> > }
>
> > Test::func();
> > exit 0;
>
> > After I executed :-
> > --------------------------------
> > $ perl test.pl 1.1
> > In 1.1/
> > In 2.2
> > In 2.2
>
> > $ perl test.pl 2.2
> > In 2.2
> > In 1.1/
> > In 1.1/
>
> > $ perl test.pl
> > In 2.2
> > In 1.1/
> > In 1.1/
>
> > ------------End----------------------
>
> > I am just a user of Perl, and don't have indepth idea about its
> > design, And the way its interpreter works.
>
> >  Would like to know your views, on how is above thing working?
> >  What is dispatch table? And
> >  Why as the per discussion threadhttp://groups.google.com/group/comp.lang.perl.misc/browse_thread/thre...
> >  it shouldnt have been working ?
>
> As was said to you in that thread - the same module will NOT be loaded
> again.  The original requirement was that, at run time, either module
> will be needed at any given moment.  To illustrate, alter your above
> example as follows:
>
> #!/usr/bin/perl
> $ver=$ARGV[0];
> if ( $ver eq '1.1' ){
>    require "./1.1/Test.pm";
>    Test::func();
>    require "./2.2/Test.pm";
>    Test::func();
>    require "./1.1/Test.pm";
>    Test::func();}else{
>
>    require "./2.2/Test.pm";
>    Test::func();
>    require "./1.1/Test.pm";
>    Test::func();
>    require "./2.2/Test.pm";
>    Test::func();}
>
> Test::func();
> exit 0;
>
> $ ./test.pl 1.1
> In 1.1/
> In 2.2
> In 2.2
> In 2.2
>
>  $ ./test.pl 2.2
> In 2.2
> In 1.1/
> In 1.1/
> In 1.1/
>
> Do you see?  require() stores the modules that have already been
> loaded, and does not load them a second time.  The second instance of
> either module being require()'d is completely ignored.
>
> That is why your solution was not applicable to the OP's stated goal.
>
> Paul Lalli


Thanks Paul.



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

Date: Wed, 30 May 2007 17:12:23 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: What is MAXINT, or when to use bigint?
Message-Id: <465d23dc$0$610$afc38c87@news.optusnet.com.au>


<bwooster47@gmail.com> wrote in message 
news:1180497176.687453.79890@q69g2000hsb.googlegroups.com...
 .
 .
>
> If I know the maximum integer I may encounter in a program, is there a
> programmatic way to determine whether to use bigint? Doing a "use
> bigint" slows down the whole thing by 40 times, in the example I am
> running, and a few tests I ran show same results with and without
> bigint.
> But - how to know for sure that I don't need bigint - if I know that
> all calculations to 2**49 are safe, that would make it sure. But not
> sure what is so magic about 2**49!
>

I think you'll find that integers up to 2  ** 53 are handled correctly by 
perl (as the "double" assigns 53 bits to its integer portion).
Unfortunately print() is not capable of reflecting that degree of 
reliability. If you use printf() and the "%f" format, you should be able to 
see that numbers up to (and including) 2 ** 53 are being handled correctly:

use warnings;
use strict;
my $x = (2 ** 53) - 1;
my $y = 2 ** 53;
my $z = (2 ** 53) + 1;
printf "%f\n%f\n%f\n", $x, $y, $z;

For me that outputs:
9007199254740991.000000
9007199254740992.000000
9007199254740992.000000

Cheers,
Rob 



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

Date: Wed, 30 May 2007 07:20:55 GMT
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: What is MAXINT, or when to use bigint?
Message-Id: <rB97i.16449$j63.15012@newsread2.news.pas.earthlink.net>

On 05/29/2007 10:52 PM, bwooster47@gmail.com wrote:
> [...]
> 2**50 = 1.12589990684262e+015
> 2**49 =  562949953421312
> 2**32 =           4294967296
> with
> use bigint;
> 2**50 = 1125899906842624
> 
> If I know the maximum integer I may encounter in a program, is there a
> programmatic way to determine whether to use bigint? Doing a "use
> bigint" slows down the whole thing by 40 times, [...]

I don't have a direct answer for your question, but I can suggest that 
you look into the GMP module; if you've installed Math::BigInt::GMP, you 
can do this at the top of your program:

use bigint qw/lib GMP/;

Another option would be to use the Math::BigInt module directly and only 
for those values that need the larger sizes.

And yet another option would be to recompile Perl with 64-bit integer 
support and not use bigint at all.




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

Date: Wed, 30 May 2007 02:02:13 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: What is MAXINT, or when to use bigint?
Message-Id: <8bidnarLyOkKoMDbnZ2dnUVZ_oavnZ2d@comcast.com>

bwooster47@gmail.com wrote:

> But - how to know for sure that I don't need bigint - if I know that
> all calculations to 2**49 are safe, that would make it sure. But not
> sure what is so magic about 2**49!

http://en.wikipedia.org/wiki/Floating_point#A_few_nice_properties

    Any integer less than or equal to 2**24 can be exactly represented
    in the single precision format, and any integer less than or equal
    to 2**53 can be exactly represented in the double precision format.
    Furthermore, any reasonable power of 2 times such a number can be
    represented. This property is sometimes used in purely integer
    applications, to get 53-bit integers on platforms that have double
    precision floats but only 32-bit integers.


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

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 V11 Issue 469
**************************************


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