[32704] in Perl-Users-Digest
Perl-Users Digest, Issue: 3968 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 17 16:09:22 2013
Date: Mon, 17 Jun 2013 13:09:08 -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 Mon, 17 Jun 2013 Volume: 11 Number: 3968
Today's topics:
constructors vs. subclasses? <oneingray@gmail.com>
Re: constructors vs. subclasses? <rweikusat@mssgmbh.com>
Re: constructors vs. subclasses? <oneingray@gmail.com>
Re: constructors vs. subclasses? <ben@morrow.me.uk>
Re: constructors vs. subclasses? <rweikusat@mssgmbh.com>
Re: constructors vs. subclasses? <ben@morrow.me.uk>
CPAN vs. POD outside of .pm (.pl) files? <oneingray@gmail.com>
Re: CPAN vs. POD outside of .pm (.pl) files? <ben@morrow.me.uk>
Re: CPAN vs. POD outside of .pm (.pl) files? <oneingray@gmail.com>
Re: Deep structure access and temp variable <willem@turtle.stack.nl>
Having trouble parsing JSON structure with JSON package <davidmichaelkarr@gmail.com>
Re: How to minimize server load when program is run <willem@turtle.stack.nl>
Re: Perl script to exe <ben@morrow.me.uk>
Re: Perl script to exe <jurgenex@hotmail.com>
Re: Perl script to exe (Tim McDaniel)
Problem with splice in a 2D ARRAY <gamo@telecable.es>
Re: Problem with splice in a 2D ARRAY <rweikusat@mssgmbh.com>
Re: Problem with splice in a 2D ARRAY <gamo@telecable.es>
Re: Problem with splice in a 2D ARRAY <ben@morrow.me.uk>
Re: Problem with splice in a 2D ARRAY <gamo@telecable.es>
Re: Problem with splice in a 2D ARRAY <rweikusat@mssgmbh.com>
Re: Problem with splice in a 2D ARRAY <rweikusat@mssgmbh.com>
Re: Problem with splice in a 2D ARRAY <ben@morrow.me.uk>
Re: Problem with splice in a 2D ARRAY <ben@morrow.me.uk>
Status of Perl for OS/2? (Seymour J.)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 17 Jun 2013 15:10:12 +0000
From: Ivan Shmakov <oneingray@gmail.com>
Subject: constructors vs. subclasses?
Message-Id: <87txkwept7.fsf@violet.siamics.net>
(ISTR that there was a discussion of this somewhere in the
Perl's documentation, but I cannot find it right now.)
So, I'm implementing a subclass SubClass to the class Class:
package SubClass;
use base 'Class';
Then, how do I write a suitable constructor for SubClass, given
that I need to associate some additional data with the object?
Indeed, I may know that the object is a reference to a hash, so:
sub new {
my ($class, $param_my, @param_super) = @_;
my $self
= Class::new ($class, @param_super)
or die ();
$self->{"SubClass::param_my"}
= $param_my;
## .
$self;
}
However, do I understand it correctly that once the Class'
author switches to, say, a reference to a list, I'm out of my
luck?
I wonder, will it help if the Class' author provided a way for
the subclasses to associate arbitrary data with the object?
Consider, e. g.:
package Class;
sub appdata {
my $self = shift;
return ($self->{"appdata"} = shift)
if (@_);
return ($self->{"appdata"});
}
package SubClass;
## a hack: replace appdata with a "nested" version?
sub appdata {
my $self = shift;
my $myself = $self->SUPER::appdata ();
return ($myself->{"appdata"} = shift)
if (@_);
return ($myself->{"appdata"});
}
sub new {
my ($class, $param_my, @param_super) = @_;
my $self
= Class::new ($class, @param_super)
or die ();
$self->SUPER::appdata ({ "param_my" => $param_my });
## .
$self;
}
And will the hack above allow for this to be repeated for
SubSubClass (and then, if done again, further)?
TIA.
--
FSF associate member #7257
------------------------------
Date: Mon, 17 Jun 2013 16:19:21 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: constructors vs. subclasses?
Message-Id: <87ip1cahom.fsf@sapphire.mobileactivedefense.com>
Ivan Shmakov <oneingray@gmail.com> writes:
> (ISTR that there was a discussion of this somewhere in the
> Perl's documentation, but I cannot find it right now.)
>
> So, I'm implementing a subclass SubClass to the class Class:
>
> package SubClass;
> use base 'Class';
>
> Then, how do I write a suitable constructor for SubClass, given
> that I need to associate some additional data with the object?
>
> Indeed, I may know that the object is a reference to a hash, so:
>
> sub new {
> my ($class, $param_my, @param_super) = @_;
> my $self
> = Class::new ($class, @param_super)
> or die ();
> $self->{"SubClass::param_my"}
> = $param_my;
> ## .
> $self;
> }
>
> However, do I understand it correctly that once the Class'
> author switches to, say, a reference to a list, I'm out of my
> luck?
If you want to do that regardless of the representation of the
superclass, you could use a hash indexed by refaddr($self)
(Scalar::Util::refaddr) to store additional attributes[*]. This will then
also need a destructor in order to delete the 'inside out' data when
an instance of the class is being destroyed.
[*] Since 'stringification' can be overloaded, the 'printed
representation' of a class can change at runtime.
------------------------------
Date: Mon, 17 Jun 2013 17:17:54 +0000
From: Ivan Shmakov <oneingray@gmail.com>
Subject: Re: constructors vs. subclasses?
Message-Id: <87ehc0ejwd.fsf@violet.siamics.net>
>>>>> Rainer Weikusat <rweikusat@mssgmbh.com> writes:
>>>>> Ivan Shmakov <oneingray@gmail.com> writes:
[...]
>> So, I'm implementing a subclass SubClass to the class Class:
>> package SubClass; use base 'Class';
>> Then, how do I write a suitable constructor for SubClass, given that
>> I need to associate some additional data with the object?
[...]
> If you want to do that regardless of the representation of the
> superclass, you could use a hash indexed by refaddr ($self)
> (Scalar::Util::refaddr) to store additional attributes [*]. This
> will then also need a destructor in order to delete the 'inside out'
> data when an instance of the class is being destroyed.
Indeed, that may work. Thanks!
Now, what if I'm facing this issue from the other side?
Is there a particular technique that'd allow for /my/ class to
be easily subclassed in the way described?
TIA.
> [*] Since 'stringification' can be overloaded, the 'printed
> representation' of a class can change at runtime.
--
FSF associate member #7257
------------------------------
Date: Mon, 17 Jun 2013 20:01:29 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: constructors vs. subclasses?
Message-Id: <91349a-rl32.ln1@anubis.morrow.me.uk>
Quoth Rainer Weikusat <rweikusat@mssgmbh.com>:
> Ivan Shmakov <oneingray@gmail.com> writes:
> > (ISTR that there was a discussion of this somewhere in the
> > Perl's documentation, but I cannot find it right now.)
> >
> > So, I'm implementing a subclass SubClass to the class Class:
> >
> > package SubClass;
> > use base 'Class';
> >
> > Then, how do I write a suitable constructor for SubClass, given
> > that I need to associate some additional data with the object?
> >
> > Indeed, I may know that the object is a reference to a hash, so:
> >
> > sub new {
> > my ($class, $param_my, @param_super) = @_;
> > my $self
> > = Class::new ($class, @param_super)
> > or die ();
> > $self->{"SubClass::param_my"}
> > = $param_my;
> > ## .
> > $self;
> > }
> >
> > However, do I understand it correctly that once the Class'
> > author switches to, say, a reference to a list, I'm out of my
> > luck?
>
> If you want to do that regardless of the representation of the
> superclass, you could use a hash indexed by refaddr($self)
> (Scalar::Util::refaddr) to store additional attributes[*]. This will then
> also need a destructor in order to delete the 'inside out' data when
> an instance of the class is being destroyed.
Don't use a plain hash for this job, use a fieldhash (created with
Hash::Util::Fieldhash). It will track object destruction automatically,
and will handle changing all the keys when a new thread is created in a
threaded perl.
Ben
------------------------------
Date: Mon, 17 Jun 2013 20:29:12 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: constructors vs. subclasses?
Message-Id: <8761xca647.fsf@sapphire.mobileactivedefense.com>
Ben Morrow <ben@morrow.me.uk> writes:
> Quoth Rainer Weikusat <rweikusat@mssgmbh.com>:
>> Ivan Shmakov <oneingray@gmail.com> writes:
[...]
>> > However, do I understand it correctly that once the Class'
>> > author switches to, say, a reference to a list, I'm out of my
>> > luck?
>>
>> If you want to do that regardless of the representation of the
>> superclass, you could use a hash indexed by refaddr($self)
>> (Scalar::Util::refaddr) to store additional attributes[*]. This will then
>> also need a destructor in order to delete the 'inside out' data when
>> an instance of the class is being destroyed.
>
> Don't use a plain hash for this job, use a fieldhash (created with
> Hash::Util::Fieldhash). It will track object destruction automatically,
> and will handle changing all the keys when a new thread is created in a
> threaded perl.
Please consider making that "I would prefer to use ... because of
...". To me, Hash::Util::Fieldhash is one of the (many) examples of
someone who felt somewhat bored and implemented some useless general
purpose library for some random something which didn't run away
quickly enough. And I generally don't care about the products of this
kind of 'recreational programming': Code should solve real problems
and not programming problems and 'abstractions' intended to do the
latter should only be introduced after very careful consideration and
if they provide significant benefits. In case of 'abstractions
provided by third party code', it is prudent to be even more careful/
reluctant wrt using them because
- they will contain bugs which will need to be dealt with at
some point in time
- they will also continue to be buggy in the 'official
version' because if the people who control the code cared
about the issue, they wouldn't be there to begin with (IOW,
I will not only need to fix the code but will be forced to
maintain a fork everthereafter)
- sooner or later, they will be changed in a
backwards-incompatible way
------------------------------
Date: Mon, 17 Jun 2013 20:51:44 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: constructors vs. subclasses?
Message-Id: <gv549a-mb42.ln1@anubis.morrow.me.uk>
Quoth Ivan Shmakov <oneingray@gmail.com>:
> (ISTR that there was a discussion of this somewhere in the
> Perl's documentation, but I cannot find it right now.)
>
> So, I'm implementing a subclass SubClass to the class Class:
>
> package SubClass;
> use base 'Class';
base.pm is deprecated. It tries to set up data inheritance using the
also-mostly-deprecated fields pragma, which is not normally useful. Use
parent.pm instead, which just sets up inheritance, or just set @ISA
directly.
> Then, how do I write a suitable constructor for SubClass, given
> that I need to associate some additional data with the object?
This has been a perennial problem with Perl OO since the beginning, so
there are lots of different solutions. ('Problem' in the sense of
'something which requires a solution', rather than 'design flaw'; there
are times when Perl's flexibility in this regard is useful, as well as
times when the lack of an 'easy things should be easy' solution is
irritating.)
The oldest is fields.pm which I mentioned above; since the intention of
this pragma was to interact with the now-removed pseudohashes feature of
perl 5005 and 5.6, it is not a lot of use these days. Nowadays it's most
common to use one of the Class::Accessor family of modules, or Moose.
Both of these deal with the problems you mention below by enforcing some
structure on the internal representation of the object. Normally they
both implement objects as hashrefs keyed by 'attribute name', though
Moose at least is capable of handling objects with other implementations
if necessary.
My recommendation would be to just use Moose. It has a certain amount of
overhead, but for that you get an extremely powerful and flexible
system.
> Indeed, I may know that the object is a reference to a hash, so:
>
> sub new {
> my ($class, $param_my, @param_super) = @_;
> my $self
> = Class::new ($class, @param_super)
> or die ();
> $self->{"SubClass::param_my"}
> = $param_my;
I would say that you should not do this: that is, you should not access
the underlying representation directly. That should be the job of some
piece of code dedicated to that purpose, either implemented directly in
the base class or pulled in from a module. Both Class::Accessor and
Moose provide ways to create new attributes in subclasses which don't
involve playing with the underlying hash directly.
> ## .
> $self;
> }
>
> However, do I understand it correctly that once the Class'
> author switches to, say, a reference to a list, I'm out of my
> luck?
You do. The simplest answer is 'don't do that': that is, the
'subclassing interface' should be considered part of the contract a
class creates, and if it changes this should be documented as a breaking
change. Unfortunately this is often not done; fortunately, a hashref
keyed by attribute name is so much the most common class representation
that it's often possible to subclass on that assumption anyway.
> I wonder, will it help if the Class' author provided a way for
> the subclasses to associate arbitrary data with the object?
> Consider, e. g.:
>
> package Class;
>
> sub appdata {
> my $self = shift;
> return ($self->{"appdata"} = shift)
> if (@_);
> return ($self->{"appdata"});
> }
>
> package SubClass;
>
> ## a hack: replace appdata with a "nested" version?
> sub appdata {
> my $self = shift;
> my $myself = $self->SUPER::appdata ();
> return ($myself->{"appdata"} = shift)
> if (@_);
> return ($myself->{"appdata"});
> }
>
> sub new {
> my ($class, $param_my, @param_super) = @_;
> my $self
> = Class::new ($class, @param_super)
You should call this as a method: Class might inherit its ->new method.
my $self = $class->Class::new(@param_super)
You should probably also consider using SUPER or (better) next::method
instead. (SUPER is only adequate for the case of single inheritance.) Or
just use Moose...
> or die ();
> $self->SUPER::appdata ({ "param_my" => $param_my });
> ## .
> $self;
> }
It's not terribly clear to me how this is supposed to work--how do you
get at 'param_my', for instance?--but I don't think it subclasses
correctly. You've carefully kept the appdata hashes for the different
classes separate, but there's only one ->appdata method, so a method in
class Class calling ->appdata will see the same hash as one in class
SubClass.
If I were going to do something like this I might do this:
package Class;
sub appdata {
my ($self, $for) = @_;
$for //= caller;
$self->{$for} ||= {};
}
and then use that in all classes, for all attributes. So:
package Class;
sub new {
my ($class, $one, $two) = @_;
my $self = bless {}, $class;
my $data = $self->appdata;
$data->{one} = $one;
$data->{two} = $two;
$self;
}
package SubClass;
sub new {
my ($class, $one, $three) = @_;
my $self = $class->Class::new($one, "default for two");
my $data = $self->appdata;
$data->{three} = $three;
$self;
}
which gives us 'package scoped' or 'class scoped' attributes, with the
possibility of peeking at other classes' attributes if we need to.
Ben
------------------------------
Date: Mon, 17 Jun 2013 14:20:10 +0000
From: Ivan Shmakov <oneingray@gmail.com>
Subject: CPAN vs. POD outside of .pm (.pl) files?
Message-Id: <87y5a8es4l.fsf@violet.siamics.net>
I see that CPAN automagically extracts the POD documentation out
of the .pm and .pl files and presents it as HTML.
However, now I decide to split the documentation off the .pm's.
How do I request CPAN to extract my documentation out of
stand-alone POD files instead? (and associate it with the
respective .pm's?)
TIA.
--
FSF associate member #7257 np. Strange Highways -- Dio
------------------------------
Date: Mon, 17 Jun 2013 16:12:03 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: CPAN vs. POD outside of .pm (.pl) files?
Message-Id: <3jl39a-9b61.ln1@anubis.morrow.me.uk>
Quoth Ivan Shmakov <oneingray@gmail.com>:
> I see that CPAN automagically extracts the POD documentation out
> of the .pm and .pl files and presents it as HTML.
What do you mean by 'CPAN'? The CPAN shell doesn't normally do this. Do
you mean search.cpan.org?
> However, now I decide to split the documentation off the .pm's.
> How do I request CPAN to extract my documentation out of
> stand-alone POD files instead? (and associate it with the
> respective .pm's?)
search.cpan.org already displays a list of all the .pod files in a
distribution under the 'Documentation' section. If a .pm file has no
Pod, and there is a .pod file next to it, it moves the .pod link up into
the 'Modules' section. See for example Net::SSLeay.
It's probably important to get the NAME section of the Pod right. I
don't exactly know how the search.cpan.org/perldoc?foo links it uses for
L<> work, but I suspect they're indexed based on the NAME section.
Ben
------------------------------
Date: Mon, 17 Jun 2013 15:39:34 +0000
From: Ivan Shmakov <oneingray@gmail.com>
Subject: Re: CPAN vs. POD outside of .pm (.pl) files?
Message-Id: <87li68eog9.fsf@violet.siamics.net>
>>>>> Ben Morrow <ben@morrow.me.uk> writes:
>>>>> Quoth Ivan Shmakov <oneingray@gmail.com>:
>> I see that CPAN automagically extracts the POD documentation out of
>> the .pm and .pl files and presents it as HTML.
> What do you mean by 'CPAN'? The CPAN shell doesn't normally do this.
> Do you mean search.cpan.org?
Yes, I've meant http://search.cpan.org/ specifically, even
though I've inaccurately referenced the whole cpan.org
infrastructure.
I didn't mean cpan(1).
>> However, now I decide to split the documentation off the .pm's. How
>> do I request CPAN to extract my documentation out of stand-alone POD
>> files instead? (and associate it with the respective .pm's?)
> search.cpan.org already displays a list of all the .pod files in a
> distribution under the 'Documentation' section. If a .pm file has no
> Pod, and there is a .pod file next to it, it moves the .pod link up
> into the 'Modules' section.
(Which makes me wonder where is it documented?)
> See for example Net::SSLeay.
> It's probably important to get the NAME section of the Pod right. I
> don't exactly know how the search.cpan.org/perldoc?foo links it uses
> for L<> work, but I suspect they're indexed based on the NAME
> section.
ACK, thanks! Hopefully, such indexing won't insist on the use
of a HYPHEN-MINUS (U+002D) there, instead of the arguably more
appropriate EN DASH (U+2013).
(FWIW, http://search.cpan.org/perldoc?Net::SSLeay appears to
work. Yet it uses the conventional HYPHEN-MINUS.)
--
FSF associate member #7257
------------------------------
Date: Mon, 17 Jun 2013 16:53:55 +0000 (UTC)
From: Willem <willem@turtle.stack.nl>
Subject: Re: Deep structure access and temp variable
Message-Id: <slrnkrufp3.oct.willem@turtle.stack.nl>
Ivan Shmakov wrote:
)>>>>> Adrien BARREAU <adrien.barreau@live.fr> writes:
)
) [...]
)
) > # Version 2
)
) > my $tmp = $stuff->{a}{b}{c}{d};
) > my $A = $tmp->{e};
) > my $B = $tmp->{f};
) > my $C = $tmp->{g};
)
) > What is the most efficient? What appears to be the most idiomatic?
)
) FWIW (and now that the experts have said their word), my
) personal preference would be to write it as follows:
)
) my $tmp = $stuff->{a}{b}{c}{d};
) my ($A, $B, $C) = @$tmp{qw (e f g)};
Writing it that way obviates the need for a temporary variable,
so why don't you write this:
my ($A, $B, $C) = @{$stuff->{a}{b}{c}{d}}{qw(e f g)};
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
------------------------------
Date: Mon, 17 Jun 2013 12:15:39 -0700 (PDT)
From: David Karr <davidmichaelkarr@gmail.com>
Subject: Having trouble parsing JSON structure with JSON package
Message-Id: <8d5b60a3-f947-4e2b-b2d5-74609069a37e@googlegroups.com>
I have a web service that returns XML or JSON, and I'm trying to write some=
code to verify the JSON form of the response. The XML verification is alr=
eady working.
The JSON looks somewhat like this (some long lists of properties replaced b=
y "..."):
{"sl.serviceCallResults":{"@latestTime":"1371493703000","sl.services":{"sl.=
service":[{"@last15SuccessRate":"0.8552632",...},{"@last15SuccessRate":"0.8=
75",...},{"@last15SuccessRate":"0.8116788",...},{"@last15SuccessRate":"0.82=
133335",...},{"@last15SuccessRate":"0.81842816",...},{"@last15SuccessRate":=
"0.7983539",...},{"@last15SuccessRate":"0.84782606",...},{"@last15SuccessRa=
te":"0.0",...}]},"sl.workflows":{"sl.workflow":[{"@latestTime":"13714937030=
00",...}]},"sl.failureExpressions":{"sl.failureExpression":["Data Error","s=
tuff"]}}}]
At this point, I'm simply trying to count the number of entries in the "sl.=
service" array.
This is what I've hacked together so far:
sub countJSONServices($) {
my ($jsonText) =3D @_;
my $json =3D JSON->new->allow_nonref;
my $scalar =3D from_json($jsonText);
printhash($scalar);
my $serviceCallResults =3D $scalar->{"sl.serviceCallResults"};
#print "serviceCallResults[" . $serviceCallResults . "]\n";
printhash($serviceCallResults);
my $services =3D $serviceCallResults->{"sl.services"};
printhash($services);
my $servicesList =3D $services->{"sl.service"};
print "servicesList[$servicesList]\n";
for my $service (@servicesList) {
print "service[$service]\n";
}
my $servicesCount =3D scalar @servicesList;
print "servicesCount[$servicesCount]\n";
return $servicesCount;
}
Where "printhash()" simply is this:
sub printhash($) {
my ($hash) =3D @_;
while ( my ($key, $value) =3D each(%{$hash}) ) {
print "$key =3D> $value\n";
}
}
The output I have at this point is this:
--------------
sl.serviceCallResults =3D> HASH(0x20d49990)
@latestTime =3D> 1371496045000
sl.workflows =3D> HASH(0x20a0d2d8)
sl.services =3D> HASH(0x20a389d8)
sl.failureExpressions =3D> HASH(0x20a0d260)
sl.service =3D> ARRAY(0x20a2bb48)
servicesList[ARRAY(0x20a2bb48)]
servicesCount[0]
--------------
Where I'm confused is that "$servicesList" should be the array of elements =
in the "sl.service" array, but it appears to have zero elements, although i=
t has 5 elements in the JSON output.
------------------------------
Date: Mon, 17 Jun 2013 17:05:16 +0000 (UTC)
From: Willem <willem@turtle.stack.nl>
Subject: Re: How to minimize server load when program is run
Message-Id: <slrnkrugeb.oct.willem@turtle.stack.nl>
Justin C wrote:
) My web-hosts are running perl 5.8.8, other software there is of a
) similar age, and some things are missing (I wanted to 'nice' my
) program, but there is no 'nice').
)
) I have written a backup program to tar and gzip my entire directory
) tree on their site, and also to dump the db and add that to the tar.
) The program I have written runs one of my cores at 100% for two
) minutes, and uses almost 100MB RAM. If there is a way I'd like to
) reduce this load (as I can't 'nice' it).
Odd, I would have expected a tar/gzip action to be I/O bound.
That is, use 100% disk read/write capacity and not as much CPU.
Have you tried how long the 'tar' command takes, how much CPU that uses,
etc? Or perhaps the database dump is the culprit. You should test those
separately.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
------------------------------
Date: Mon, 17 Jun 2013 15:55:52 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Perl script to exe
Message-Id: <okk39a-9b61.ln1@anubis.morrow.me.uk>
Please don't double-space your quotes. I know Google does it by default;
please either find out how to turn it off or stop using Google.
Please don't reply to yourself. Instead, take a little more time before
posting in the first place to make sure you've mentioned everything
relevant.
Quoth jis <jismagic@gmail.com>:
> On Monday, June 17, 2013 12:56:09 PM UTC+5:30, jis wrote:
> > On Saturday, June 15, 2013 3:16:56 PM UTC+5:30, jis wrote:
> > >
> > > I have used perl2exe on windows xp platform to convert perl
> > > script to exe. But since windows 7, it has not been dependable.
> > > par pp also do not look like it works on all windows 7 machines. I
> > > have googled it and didnt find anyting significant. Please let me
> > > know what you guys use on windows 7 platform to get it working..
> >
> > Since nobody replied to message yet, I have to ask for another
> > help. How do i run a standalone created on 64 bit wndows 7 run on a
> > 32 bit windows 7. I get an incompatibility errror when i do this..
>
> Forgot to mention that Im using Par pp..
If you've created a 64-bit executable then I don't think you can. The
only OS I know of that will run 64-bit executables on a 32-bit OS is Mac
OS.
Ben
------------------------------
Date: Mon, 17 Jun 2013 09:02:33 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Perl script to exe
Message-Id: <9dcur89hjorisng6365jkq59r16arvmheg@4ax.com>
jis <jismagic@gmail.com> wrote:
>On Monday, June 17, 2013 12:56:09 PM UTC+5:30, jis wrote:
>> On Saturday, June 15, 2013 3:16:56 PM UTC+5:30, jis wrote:
>>
>> > I have used perl2exe on windows xp platform to convert perl script to exe.
[seven empty lines deleted. Please don't add random empty lines, it
makes reading your text rather difficult]
What goal are you trying to achive by using perl2exe (there could be
several, and alternative solutions would depend upon what you actully
trying to achive).
>> > But since windows 7, it has not been dependable.
[seven empty lines deleted. Please don't add random empty lines, it
makes reading your text rather difficult]
perl2exe never was dependable but has alway been a crutch with better
alternatives for most purposes.
>> > Please let me know what you guys use on windows 7 platform to get it working..
[seven empty lines deleted. Please don't add random empty lines, it
makes reading your text rather difficult]
That depends upon what "it" really is.
>> How do i run a standalone created on 64 bit wndows 7 run on a 32 bit windows 7.
[three empty lines deleted. Please don't add random empty lines, it
makes reading your text rather difficult]
>> I get an incompatibility errror when i do this..
[three empty lines deleted. Please don't add random empty lines, it
makes reading your text rather difficult]
Not surprising. Usually you cannot run a 64-bit executable on a 32-bit
OS.
jue
------------------------------
Date: Mon, 17 Jun 2013 16:48:58 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: Perl script to exe
Message-Id: <kpnelq$iii$1@reader1.panix.com>
In article <9dcur89hjorisng6365jkq59r16arvmheg@4ax.com>,
J_rgen Exner <jurgenex@hotmail.com> wrote:
>[seven empty lines deleted. Please don't add random empty lines, it
>makes reading your text rather difficult]
I gather that Google is starting to do that. I have not heard that
people control that -- but to anyone along the way who is able to
remove them (Google users when replying, say), please do so.
--
Tim McDaniel, tmcd@panix.com
------------------------------
Date: Mon, 17 Jun 2013 11:04:24 +0000 (UTC)
From: gamo <gamo@telecable.es>
Subject: Problem with splice in a 2D ARRAY
Message-Id: <kpmqfo$anc$1@speranza.aioe.org>
Hello, I have a 2D array and want to interchange rows and columns.
I have done this test and it fails talking about flips and flops.
The perldoc -f splice is not of much help to swap 2 rows in a 2D
array (4 parameters as argument).
#!/usr/local/bin/perl -W
for $x (0,1){
for $y (0,1){
$xy[$x][$y]= ++$count;
}
}
splice @xy, 0, 1, $xy[1][0..1];
for $x (0,1){
for $y (0,1){
print "$xy[$x][$y] ";
}
print "\n";
}
__END__
Thanks in advance for any help
------------------------------
Date: Mon, 17 Jun 2013 12:57:17 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: Problem with splice in a 2D ARRAY
Message-Id: <87ppvl9cgy.fsf@sapphire.mobileactivedefense.com>
gamo <gamo@telecable.es> writes:
> Hello, I have a 2D array and want to interchange rows and columns.
>
> I have done this test and it fails talking about flips and flops.
> The perldoc -f splice is not of much help to swap 2 rows in a 2D
> array (4 parameters as argument).
>
> #!/usr/local/bin/perl -W
>
> for $x (0,1){
> for $y (0,1){
> $xy[$x][$y]= ++$count;
> }
> }
There is no such thing as 'a 2D array' in Perl. What you create here
is a two-element array containing two references to two anonymous
two-element arrays each containing two numbers. Swapping the two
'rows' aka 'anonymous two-element arrays' can be done with
@xy[0,1] = @xy[1,0]
or
splice(@xy, 0, 2, @xy[1,0])
------------------------------
Date: Mon, 17 Jun 2013 14:43:23 +0200 (CET)
From: gamo <gamo@telecable.es>
Subject: Re: Problem with splice in a 2D ARRAY
Message-Id: <kpn09a$re9$1@speranza.aioe.org>
Rainer Weikusat <rweikusat@mssgmbh.com> Wrote in message:
> gamo <gamo@telecable.es> writes:
>> Hello, I have a 2D array and want to interchange rows and columns.
>>
>> I have done this test and it fails talking about flips and flops.
>> The perldoc -f splice is not of much help to swap 2 rows in a 2D
>> array (4 parameters as argument).
>>
>> #!/usr/local/bin/perl -W
>>
>> for $x (0,1){
>> for $y (0,1){
>> $xy[$x][$y]= ++$count;
>> }
>> }
>
> There is no such thing as 'a 2D array' in Perl. What you create here
> is a two-element array containing two references to two anonymous
> two-element arrays each containing two numbers. Swapping the two
> 'rows' aka 'anonymous two-element arrays' can be done with
>
> @xy[0,1] = @xy[1,0]
>
> or
>
> splice(@xy, 0, 2, @xy[1,0])
>
Both works fine, but as I infer there is no simple way to do that
by columns.
thank you very much
--
posted by mobile device
----Android NewsGroup Reader----
http://www.piaohong.tk/newsgroup
------------------------------
Date: Mon, 17 Jun 2013 16:02:27 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Problem with splice in a 2D ARRAY
Message-Id: <31l39a-9b61.ln1@anubis.morrow.me.uk>
Quoth gamo <gamo@telecable.es>:
>
> Hello, I have a 2D array and want to interchange rows and columns.
Well, did you try the obvious way?
my @old = ...;
my @new;
for my $r (0..$#old) {
my $row = $old[$r];
for my $c (0..$#$row) {
$new[$c][$r] = $$row[$c];
}
}
I'm not sure it's possible to do that any more elegantly, given that you
can't take a slice vertically through a 2d array.
> I have done this test and it fails talking about flips and flops.
> The perldoc -f splice is not of much help to swap 2 rows in a 2D
> array (4 parameters as argument).
>
> #!/usr/local/bin/perl -W
>
> for $x (0,1){
> for $y (0,1){
> $xy[$x][$y]= ++$count;
> }
> }
>
> splice @xy, 0, 1, $xy[1][0..1];
What did you expect this to do? The 0..1 is in scalar context, so this
is the flip-flop operator, which I don't think is what you meant.
Ben
------------------------------
Date: Mon, 17 Jun 2013 16:31:27 +0000 (UTC)
From: gamo <gamo@telecable.es>
Subject: Re: Problem with splice in a 2D ARRAY
Message-Id: <kpndkv$5n8$1@speranza.aioe.org>
for my $r (0..$#old) {
my $row = $old[$r];
for my $c (0..$#$row) {
$new[$c][$r] = $$row[$c];
}
}
I'm not sure it's possible to do that any more elegantly, given that you
can't take a slice vertically through a 2d array.
--------------------
Well, that does a tansposition, and after that is posible to do the
column swap:
my @xy = @new;
for $y (0,1){
($xy[0][$y],$xy[1][$y]) = ($xy[1][$y],$xy[0][$y]);
}
and redo the transposition. Or directly,
for $x (0,1){
($xy[$x][0],$xy[$x][1]) = ($xy[$x][1],$xy[$x][0]);
}
Anyway, it could be done without splice. Thank you, I'll try to resume
it to work with randomized small square matrix.
Best regards,
------------------------------
Date: Mon, 17 Jun 2013 17:57:41 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: Problem with splice in a 2D ARRAY
Message-Id: <87ehc0ad4q.fsf@sapphire.mobileactivedefense.com>
Ben Morrow <ben@morrow.me.uk> writes:
> Quoth gamo <gamo@telecable.es>:
>>
>> Hello, I have a 2D array and want to interchange rows and columns.
>
> Well, did you try the obvious way?
>
> my @old = ...;
> my @new;
>
> for my $r (0..$#old) {
> my $row = $old[$r];
> for my $c (0..$#$row) {
> $new[$c][$r] = $$row[$c];
> }
> }
>
> I'm not sure it's possible to do that any more elegantly, given that you
> can't take a slice vertically through a 2d array.
sub transpose
{
my $in = $_[0];
my (@out, $col);
for $col (0 .. $#{$in->[0]}) {
push(@out, [map { $_->[$col] } @$in[0 .. $#$in]])
}
return \@out;
}
my @a = ([1,2,3,4], [4,5,6,7], [7,8,9,10]);
my $at = transpose(\@a);
for (@$at) {
print("$_ ") for @$_;
print("\n");
}
------------------------------
Date: Mon, 17 Jun 2013 18:11:32 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: Problem with splice in a 2D ARRAY
Message-Id: <87a9moachn.fsf@sapphire.mobileactivedefense.com>
Rainer Weikusat <rweikusat@mssgmbh.com> writes:
[...]
> push(@out, [map { $_->[$col] } @$in[0 .. $#$in]])
This is, of course, equivalent to
push(@out, [map { $_->[$col] } @$in])
------------------------------
Date: Mon, 17 Jun 2013 19:58:23 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Problem with splice in a 2D ARRAY
Message-Id: <fr249a-rl32.ln1@anubis.morrow.me.uk>
Please quote properly, and attribute your quotations.
Quoth gamo <gamo@telecable.es>:
> [I wrote:]
>> for my $r (0..$#old) {
>> my $row = $old[$r];
>> for my $c (0..$#$row) {
>> $new[$c][$r] = $$row[$c];
>> }
>> }
>>
>> I'm not sure it's possible to do that any more elegantly, given that you
>> can't take a slice vertically through a 2d array.
>
> Well, that does a tansposition,
Yes. You asked how to interchange rows and columns; that's what a
transposition does.
> and after that is posible to do the
> column swap:
>
> my @xy = @new;
>
> for $y (0,1){
> ($xy[0][$y],$xy[1][$y]) = ($xy[1][$y],$xy[0][$y]);
> }
>
> and redo the transposition. Or directly,
>
> for $x (0,1){
> ($xy[$x][0],$xy[$x][1]) = ($xy[$x][1],$xy[$x][0]);
> }
So you're actually trying to exchange two columns. Yes, that is the way
to do it. For the more general case of reversing the columns of a NxM
matrix, you want
for my $r (@matrix) {
splice @$r, 0, $#r, reverse @$r;
}
You should look on CPAN: a lot of this sort of basic stuff has already
been implemented.
Ben
------------------------------
Date: Mon, 17 Jun 2013 19:50:50 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Problem with splice in a 2D ARRAY
Message-Id: <ad249a-rl32.ln1@anubis.morrow.me.uk>
Quoth Rainer Weikusat <rweikusat@mssgmbh.com>:
> Ben Morrow <ben@morrow.me.uk> writes:
> > Quoth gamo <gamo@telecable.es>:
> >>
> >> Hello, I have a 2D array and want to interchange rows and columns.
> >
> > Well, did you try the obvious way?
> >
> > my @old = ...;
> > my @new;
> >
> > for my $r (0..$#old) {
> > my $row = $old[$r];
> > for my $c (0..$#$row) {
> > $new[$c][$r] = $$row[$c];
> > }
> > }
> >
> > I'm not sure it's possible to do that any more elegantly, given that you
> > can't take a slice vertically through a 2d array.
>
> sub transpose
> {
> my $in = $_[0];
> my (@out, $col);
>
> for $col (0 .. $#{$in->[0]}) {
> push(@out, [map { $_->[$col] } @$in[0 .. $#$in]])
> }
Yes, that's the same algorithm, just with map instead of for, though it
probably is worth pointing out that
map $_->[$col], @2d;
is the way to take a vertical slice.
Ben
------------------------------
Date: Mon, 17 Jun 2013 12:44:23 -0400
From: Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid>
Subject: Status of Perl for OS/2?
Message-Id: <51bf3ce7$17$fuzhry+tra$mr2ice@news.patriot.net>
The perldelta for 5.18 suggests that if nobody is actively working on
Perl for OS/2 then the Perl developers may drop the OS/2 related code.
I'm currently using Perl 5.10; Perl 5.14 had path rewriter issues and
I'm not aware of a more recent build for OS/2. Is anybody in the OS/2
community working on Perl 5.16 or 5.18, and, if so, have they made
themselves known to the Perl developers?
Thanks.
--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>
Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to spamtrap@library.lspace.org
------------------------------
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 3968
***************************************