[32000] in Perl-Users-Digest
Perl-Users Digest, Issue: 3264 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 22 21:09:31 2011
Date: Sat, 22 Jan 2011 18:09:10 -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, 22 Jan 2011 Volume: 11 Number: 3264
Today's topics:
Re: How can I migrate a Linux Perl installation <no-one_you-know@not-at-this-address.com>
Re: Learning Object Oriented Programming (newbie) <rodbass63@gmail.com>
Re: Learning Object Oriented Programming (newbie) <rodbass63@gmail.com>
Re: Memory limit question sln@netherlands.com
Re: Memory limit question <hjp-usenet2@hjp.at>
Re: Memory limit question <edgrsprj@ix.netcom.com>
Re: Memory limit question <m@rtij.nl.invlalid>
Perl and Linux <edgrsprj@ix.netcom.com>
Re: Perl and Linux <m@rtij.nl.invlalid>
Re: Perl and Linux <edgrsprj@ix.netcom.com>
Re: Perl and Linux <Uno@example.invalid>
Re: Perl and Linux <Uno@example.invalid>
Re: what is the cheapest way to just initialize a hash <jwkrahn@example.com>
Re: what is the cheapest way to just initialize a hash <rvtol+usenet@xs4all.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 22 Jan 2011 19:39:09 GMT
From: pete <no-one_you-know@not-at-this-address.com>
Subject: Re: How can I migrate a Linux Perl installation
Message-Id: <slrnijmcjf.a1d.no-one_you-know@corv.local>
On Wed, 05 Jan 2011 12:11:41 -0500, Sherm Pendley wrote:
> pete <no-one_you-know@not-at-this-address.com> writes:
>
>> I have an AMD64 machine running Ubuntu 8.04 with a _lot_ of
>> perl modules installed. I have a need to replicate the same
>> set of libraries on a different box running a later version
>> of Ubuntu - probably 10.04 but possibly 10.10. However the
>> new box will be a 32-bit version, not the 64 bit system I am
>> running here.
>>
>> Now I could settle in for a long session in front of a
>> perl -MCPAN -e shell prompt and pull stuff across manually.
>> However, this would take a long time and I would probably
>> miss a few modules.
>> I also expect that some will break, some will need hacking
>> and some will have been obsoleted - the original install
>> is a few years old.
>>
>> Is there a more reliable way I could audit the modules I
>> have on the original box and have the same modules installed
>> on the new system? If it took care of dependencies, that
>> would be even better.
>
> Odd that no one has mentioned the CPAN shell's "autobundle" command.
> It will create a Bundle:: distribution that references all of your
> installed modules. You copy that into ~/.cpan/Bundle/ on your target
> machine, then "install Bundle::blahblah."
>
> sherm--
>
Thanks Sherm, that sounds very promising. As with "there's more
than one way to do it", with Perl you can expect that pretty
much every problem has been encountered before and a solution
produced. It's just a case of finding someone sufficiently
well traveled to help you find it.
--
http://thisreallyismyhost.99k.org/2220110119305510563.php
------------------------------
Date: Fri, 21 Jan 2011 19:18:22 -0800 (PST)
From: Nene <rodbass63@gmail.com>
Subject: Re: Learning Object Oriented Programming (newbie)
Message-Id: <bd3cbecf-20bc-4391-ae09-2e62456331dd@v17g2000yqv.googlegroups.com>
On Jan 21, 6:39=A0pm, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> On 2011-01-21 13:52, Nene <rodbas...@gmail.com> wrote:
>
> > =A0I have another question. The $farm and $port belong to an environmen=
t
> > that I want to do something with down the road in the print_variable
> > method. But I have multiple kinds of $farm and $port variables that I
> > want to do something with at the same time.
>
> > Presently, I have $farm =3D WEB, and port =3D 1234. But I also have a
> > $farm =3D "ABC", port =3D "2345, and $farm =3D "XYZ" and $port =3D "987=
6" and
> > I want to apply those to the print_variables method as well. Can
> > somebody point me in the right direction?
>
> I'm not sure whether I understand you correctly. Part of the problem is
> that you named your class "Learn", and I have a hard time figuring out
> what kind of thing a "Learn" might be which has a "farm" and a "port".
I named this package with the name Learn so I can let the readers of
this newsgroup to understand
that this is basically my first OOP in Perl and I'm basically learning
how to create a simple object
to hold data which I will do something with down the road.
>
> I am assuming that you want to have many "Learn" thingies, each of which
> has exactly one farm and one port. Then your class is already ok and you
> can just create many "Learn" objects with your new method:
Basically a 'farm' is a VIP (ip address) and 'port' is a port that is
listening on the 'farm'.
I should have called this package IP::PORT for our readers to
understand.
>
> =A0 =A0 my $learn_web =3D Learn->new();
> =A0 =A0 $learn_web->set_farm('WEB');
> =A0 =A0 $learn_web->set_port(1234);
>
> =A0 =A0 my $learn_abc =3D Learn->new();
> =A0 =A0 $learn_abc->set_farm('ABC');
> =A0 =A0 $learn_abc->set_port(2345);
>
> =A0 =A0 my $learn_xyz =3D Learn->new();
> =A0 =A0 $learn_xyz->set_farm('AXYZ);
> =A0 =A0 $learn_xyz->set_port(9876);
>
> =A0 =A0 $learn_web->print_variables();
> =A0 =A0 $learn_abc->print_variables();
> =A0 =A0 $learn_xyz->print_variables();
>
> or (almost equivalent):
>
> =A0 =A0 my @learn_thingies;
> =A0 =A0 my $learn_thing;
>
> =A0 =A0 $learn_thing =3D Learn->new();
> =A0 =A0 $learn_thing->set_farm('WEB');
> =A0 =A0 $learn_thing->set_port(1234);
> =A0 =A0 push @learn_thingies, @learn_thing;
>
> =A0 =A0 $learn_thing =3D Learn->new();
> =A0 =A0 $learn_thing->set_farm('ABC');
> =A0 =A0 $learn_thing->set_port(2345);
> =A0 =A0 push @learn_thingies, @learn_thing;
>
> =A0 =A0 $learn_thing =3D Learn->new();
> =A0 =A0 $learn_thing->set_farm('AXYZ);
> =A0 =A0 $learn_thing->set_port(9876);
> =A0 =A0 push @learn_thingies, @learn_thing;
>
> =A0 =A0 $_->print_variables() for (@learn_thingies);
>
> =A0 =A0 =A0 =A0 hp
------------------------------
Date: Sat, 22 Jan 2011 07:10:42 -0800 (PST)
From: Nene <rodbass63@gmail.com>
Subject: Re: Learning Object Oriented Programming (newbie)
Message-Id: <09fbb99b-c9da-4fe2-bfbf-37c93b532f12@s5g2000yqm.googlegroups.com>
On Jan 21, 6:25=A0pm, Sherm Pendley <sherm.pend...@gmail.com> wrote:
> Nene <rodbas...@gmail.com> writes:
> > On Jan 21, 11:30=A0am, Sherm Pendley <sherm.pend...@gmail.com> wrote:
> >> Nene <rodbas...@gmail.com> writes:
> >> > Presently, I have $farm =3D WEB, and port =3D 1234. But I also have =
a
> >> > $farm =3D "ABC", port =3D "2345, and $farm =3D "XYZ" and $port =3D "=
9876" and
> >> > I want to apply those to the print_variables method as well. Can
> >> > somebody point me in the right direction?
>
> >> You could store your data as a hash called "farms," and read/write it
> >> like so:
>
> >> sub setPortForFarm {
> >> =A0 =A0 my ($self, $port, $farm) =3D @_;
> >> =A0 =A0 $self->{'farms'}->{$farm} =3D $port;
>
> >> }
>
> >> sub portForFarm {
> >> =A0 =A0 my ($self, $farm) =3D @_;
> >> =A0 =A0 return $self->{'farms'}->{$farm};
>
> >> }
>
> >> You'd call the above with:
>
> >> =A0 my $farms =3D Farms->new();
> >> =A0 $farms->setPortForFarm(1234, 'WEB');
> >> =A0 $farms->setPortForFarm(8675309, 'Jenny');
>
> >> For more about hashes of hashes, lists of lists, etc., see:
>
> >> =A0 perldoc perlreftut
> >> =A0 perldoc perldsc
> >> =A0 perldoc perllol
>
> > Thanks Sherm.
>
> > I changed my .pm file and inputted what you suggested above:
>
> > sub setPortForFarm {
> > =A0 =A0 =A0my ($self, $port, $farm) =3D @_;
> > =A0 =A0 =A0$self->{'farms'}->{$farm} =3D $port;
>
> > =A0}
>
> > =A0sub portForFarm {
> > =A0 =A0 =A0my ($self, $farm) =3D @_;
> > =A0 =A0 =A0return $self->{'farms'}->{$farm};
>
> > In my perl script when I called the method portForFarm, it failed.
>
> Of course - you didn't pass an argument to it.
Thank you for clarifying, this is new to me. I'm enjoying the powers
of OOP.
>
> =A0 my $port =3D $farms->portForFarm('Jenny');
>
> > This is how I called it. I'm assuming since the
> > portForFarm had the return statement, it will print the data.
>
> Why would you assume that? "print" ne "return". The latter returns a
> value to the caller. So, after doing the above:
>
> =A0 print "$port\n";
>
> Will print "8675309".
>
> > I'm getting this error:
> > Use of uninitialized value $farm in hash element at /usr/lib/perl/5.10/
> > Learn.pm line 53.
>
> > Line 53 had this =A0 =A0.... =A0 return $self->{'farms'}->{$farm};
>
> Right - $farm is uninitialized, because you didn't pass a value for the
> argument when you wrote "$farms->portForFarm()".
I understand now, thanks.
>
> sherm--
>
> --
> Sherm Pendley
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<h=
ttp://camelbones.sourceforge.net>
> Cocoa Developer
------------------------------
Date: Sat, 22 Jan 2011 04:04:34 -0800
From: sln@netherlands.com
Subject: Re: Memory limit question
Message-Id: <4jglj698e6ro89m9grstkf22933eogdsqm@4ax.com>
On Sat, 22 Jan 2011 00:21:39 +0100, "Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
>On 2011-01-21 16:26, sln@netherlands.com <sln@netherlands.com> wrote:
>> On Thu, 20 Jan 2011 12:26:12 -0600, "E.D.G." <edgrsprj@ix.netcom.com> wrote:
>>
>>>"Peter J. Holzer" <hjp-usenet2@hjp.at> wrote in message
>>>news:slrnijc4ih.k4u.hjp-usenet2@hrunkner.hjp.at...
>>>> On 2011-01-18 00:27, E.D.G. <edgrsprj@ix.netcom.com> wrote:
>>>>> The ActiveState version of Perl is being used with Windows XP and
>>>>> Vista on standard PC computers.
>>>>>
>>>>> QUESTION: Does Perl have a limit on how much memory it can use
>>>>> with Windows XP and Vista?
>>>>
>>>> 32 bit or 64 bit Windows?
>>>
>>>> 32 Bit Windows has a 2 GB limit per process.
>>>
>[...]
>> To start, virtual address space for XP/Vista 32-bit is 4 gig.
>> The OS claims the high 'half' of that, ie: 2 gigs. This leaves
>> 2 gig of virtual space for user mode.
>> So 'user mode (2gig)' + 'kernel mode (2gig)' = total virtual address space (4gig).
>
>Correct.
>
>
>> So, if Windows had access to all 4 gig's of physical ram (with modern cpu's and
>> motherboard IOMMU/hardware virtualization it can be done),
>
>Intel 32 bit CPUs (since the Pentium Pro introduced in 1995) can address
>64 GB of physical RAM (they have a 36 bit address bus - google "PAE" for
>details).
>
>
>> So your application can allocate 2 gigs of physical ram right out of the gate.
>> The next app can allocate 1.5 gigs. Both of the apps will exist in physical ram
>> at the same time. You can start another app, allocate 2 gigs and the first app
>> will be swapped out to the page file. Now olny the second and third app will exist
>> in physical ram. And on and on..
>
>This is wrong. Windows (or any other OS released in the last 20+ years)
>does not swap whole processes at a time. Instead it swaps pages of
>4 kB. If you have 3 processes with 2, 1.5 and 2 GB virtual memory in a
>machine with 4 GB of physical RAM, each process will have some parts in
>RAM and some parts in the page file. The OS tries to keep those parts
>which are frequently accessed in RAM and those which are used only
>infrequently (or not at all) in the page file.
>
Thanks Peter. Yea I know this, I was just making a macro example.
I have a question, a process thread's share the same code segment. Does that mean
each can allocate independent physical ram up to
(2gig - code size) = (virtual space available per thread) ?
Although shared memory dprobably ecreases available per thread space.
-sln
------------------------------
Date: Sat, 22 Jan 2011 17:41:01 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Memory limit question
Message-Id: <slrnijm24u.4rn.hjp-usenet2@hrunkner.hjp.at>
On 2011-01-22 12:04, sln@netherlands.com <sln@netherlands.com> wrote:
> I have a question, a process thread's share the same code segment. Does that mean
> each can allocate independent physical ram up to
> (2gig - code size) = (virtual space available per thread) ?
No, threads normally share the complete virtual address space, although
details may vary from OS to OS.
hp
------------------------------
Date: Sat, 22 Jan 2011 17:15:08 -0600
From: "E.D.G." <edgrsprj@ix.netcom.com>
Subject: Re: Memory limit question
Message-Id: <xZ-dnRQ2n_5m-abQnZ2dnUVZ_uadnZ2d@earthlink.com>
<sln@netherlands.com> wrote in message
news:4qajj6h0r9qrq0rpeqgu0fch3nbr65gv2u@4ax.com...
> So basically that leaves about at least 3 gigs of physical ram for ALL
> applications combined, with the limit of each process (because of virtual
> user/kernel
> enforced space partition of 2 gig's per) being 2 gig of physical ram.
After doing some checking on this,
According to what I have been reading, Windows Vista will let you use
four times as much virtual memory (disk swap space) as you have Ram memory
on your system. So with my system that has 4 gigabytes of memory, Vista
should be able to access 16 gigabytes of virtual memory.
Vista and XP appear to make the necessary adjustments largely
automatically. As if they need more virtual memory they reset their
internal controls for that increased amount. I was able to run as many
copies of my Perl program as desired at the same time on my Vista system and
the amount of virtual memory Windows used just kept increasing when each new
copy of the program started running.
However, I had to let each program get to a point where it stopped
active processing and started waiting for keyboard input before starting the
next copy. If multiple programs are trying to do calculations etc. and are
calling for Ram memory usage Windows can be quite slow in swapping
information back and forth from the virtual memory area on the disk.
As my Perl - Gnuplot computer program is being made available as a
freeware download to governments and independent researchers around the
world I am now looking into the possibility of getting a version running
with Linux and plan to ask a question regarding that in a new thread.
------------------------------
Date: Sun, 23 Jan 2011 00:41:55 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Memory limit question
Message-Id: <3j6s08-tg4.ln1@news.rtij.nl>
On Sat, 22 Jan 2011 17:15:08 -0600, E.D.G. wrote:
> <sln@netherlands.com> wrote in message
> news:4qajj6h0r9qrq0rpeqgu0fch3nbr65gv2u@4ax.com...
>
>> So basically that leaves about at least 3 gigs of physical ram for ALL
>> applications combined, with the limit of each process (because of
>> virtual user/kernel
>> enforced space partition of 2 gig's per) being 2 gig of physical ram.
>
> After doing some checking on this,
>
> According to what I have been reading, Windows Vista will let you
> use
> four times as much virtual memory (disk swap space) as you have Ram
> memory on your system. So with my system that has 4 gigabytes of
> memory, Vista should be able to access 16 gigabytes of virtual memory.
No, any process is *also* limited by the global limitations. So if you
have 256MB of RAM, your process may access 1MB of memory, but is you have
4G, your process is still limited to 2GB of memory.
M4
------------------------------
Date: Sat, 22 Jan 2011 17:16:44 -0600
From: "E.D.G." <edgrsprj@ix.netcom.com>
Subject: Perl and Linux
Message-Id: <-qSdnfABp8rK-KbQnZ2dnUVZ_vidnZ2d@earthlink.com>
The ActiveState version of Perl runs quite well with Windows. Can anyone
comment on how well it runs with Linux?
Is Linux actually the preferred operating system for Perl? Or might that be
Unix?
------------------------------
Date: Sun, 23 Jan 2011 00:39:03 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Perl and Linux
Message-Id: <nd6s08-tg4.ln1@news.rtij.nl>
On Sat, 22 Jan 2011 17:16:44 -0600, E.D.G. wrote:
> The ActiveState version of Perl runs quite well with Windows. Can
> anyone comment on how well it runs with Linux?
Almost all distributions of Linux come with a recent version of Perl. (If
they don't, they're either really specialized or a fringe distribution).
> Is Linux actually the preferred operating system for Perl? Or might
> that be Unix?
I'm not sure, but most Unix like platforms have a recent version of Perl.
Certainly, with most Linux distributions you cannot go wrong.
HTH,
M4
------------------------------
Date: Sat, 22 Jan 2011 18:00:31 -0600
From: "E.D.G." <edgrsprj@ix.netcom.com>
Subject: Re: Perl and Linux
Message-Id: <Gd6dnWz3hfAD8qbQnZ2dnUVZ_vWdnZ2d@earthlink.com>
"Martijn Lievaart" <m@rtij.nl.invlalid> wrote in message
news:nd6s08-tg4.ln1@news.rtij.nl...
> Almost all distributions of Linux come with a recent version of Perl. (If
> they don't, they're either really specialized or a fringe distribution).
Thanks for the response.
In one of the Linux Newsgroups I am asking some questions regarding
the possible availability of a version of Linux that will run on a system
that is actually running Windows. If something like that does exist then I
might try to develop versions of my freeware download Perl – Gnuplot
computer programs that would run on a Linux system instead of Windows. And
they would then be able to run on both standalone Linux systems and that
Windows – Linux system.
------------------------------
Date: Sat, 22 Jan 2011 17:15:54 -0700
From: Uno <Uno@example.invalid>
Subject: Re: Perl and Linux
Message-Id: <8q1a9sFommU1@mid.individual.net>
On 01/22/2011 04:16 PM, E.D.G. wrote:
> The ActiveState version of Perl runs quite well with Windows. Can anyone
> comment on how well it runs with Linux?
>
> Is Linux actually the preferred operating system for Perl? Or might that
> be Unix?
>
It's not often that I feel qualified to answer questions here, but I
think I know what you're asking.
You sound like you have a background like mine, coming from windows. I
used activestate for years until I made the big switch to linux. Perl
runs natively here.
I spent a lot of time trying to find the equivalent tools over here that
I had there, but now I'm going a different direction. I'm not looking
for the suites that we know well from the windows world; I'm going back
to vi, in part because Todd Mclellan does it too, and I think imitating
those who deal with a syntax successfully is a good way to go about it.
So here's my first cheat sheet:
http://www.fprintf.net/vimCheatSheet.html
Activestate has a huge amount of functionality beyond what vi might
offer, but I found those extra capabilities (project building, for
example) to be way over my head for what I was gonna do with perl as a
guy who is still learning.
I guarantee you won't disappointed by buying _Learning Perl_.
Cheers,
--
Uno
------------------------------
Date: Sat, 22 Jan 2011 17:17:09 -0700
From: Uno <Uno@example.invalid>
Subject: Re: Perl and Linux
Message-Id: <8q1ac5FommU2@mid.individual.net>
On 01/22/2011 05:00 PM, E.D.G. wrote:
> "Martijn Lievaart" <m@rtij.nl.invlalid> wrote in message
> news:nd6s08-tg4.ln1@news.rtij.nl...
>
>> Almost all distributions of Linux come with a recent version of Perl. (If
>> they don't, they're either really specialized or a fringe distribution).
>
> Thanks for the response.
>
> In one of the Linux Newsgroups I am asking some questions regarding the
> possible availability of a version of Linux that will run on a system
> that is actually running Windows. If something like that does exist then
> I might try to develop versions of my freeware download Perl – Gnuplot
> computer programs that would run on a Linux system instead of Windows.
> And they would then be able to run on both standalone Linux systems and
> that Windows – Linux system.
>
Sounds like you want cygwin.
--
Uno
------------------------------
Date: Fri, 21 Jan 2011 23:45:04 -0800
From: "John W. Krahn" <jwkrahn@example.com>
Subject: Re: what is the cheapest way to just initialize a hash key?
Message-Id: <4Wv_o.59$BE3.17@newsfe08.iad>
jidanni@jidanni.org wrote:
> Gentlemen, I'm only interested in the keys to my hash,
> what is the cheapest way to just initialize the key? Who cares about values.
> for (...) { $myhash{ f($_) }++ } #or yet cheaper:
> for (...) { $myhash{ f($_) } = 1 } #or yet cheaper still?:
> for (...) { $myhash{ f($_) } = undef } #anything even yet more cheaper?
> print keys %myhash;
> (No I don't want to use an array, as I might be adding a key twice and
> would rather not notice it.)
@myhash{ ... } = ();
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
------------------------------
Date: Sat, 22 Jan 2011 17:41:54 +0100
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: what is the cheapest way to just initialize a hash key?
Message-Id: <4d3b08d2$0$81476$e4fe514c@news.xs4all.nl>
On 2011-01-22 08:45, John W. Krahn wrote:
> jidanni@jidanni.org wrote:
>> Gentlemen, I'm only interested in the keys to my hash,
>> what is the cheapest way to just initialize the key? Who cares about
>> values.
>> for (...) { $myhash{ f($_) }++ } #or yet cheaper:
>> for (...) { $myhash{ f($_) } = 1 } #or yet cheaper still?:
>> for (...) { $myhash{ f($_) } = undef } #anything even yet more cheaper?
>> print keys %myhash;
>> (No I don't want to use an array, as I might be adding a key twice and
>> would rather not notice it.)
>
> @myhash{ ... } = ();
Indeed. The only way to beat that is to make all values be the same SV.
See Data::Alias (or Array::RefElem) for how to do that.
You can also compile all keys into a regex.
--
Ruud
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 3264
***************************************