[30260] in Perl-Users-Digest
Perl-Users Digest, Issue: 1503 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 2 11:09:45 2008
Date: Fri, 2 May 2008 08:09:09 -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 Fri, 2 May 2008 Volume: 11 Number: 1503
Today's topics:
Deeper level of hashing <dn.perl@gmail.com>
Re: Deeper level of hashing <joost@zeekat.nl>
Re: Help: Reverse Letters <jurgenex@hotmail.com>
Re: Help: Reverse Letters <RedGrittyBrick@SpamWeary.foo>
Re: Help: Reverse Letters <RedGrittyBrick@SpamWeary.foo>
Re: Python's doc problems: sort <gneuner2/@/comcast.net>
Re: Stuffing @users into $self->{'users'} <Phillip.Ross.Taylor@gmail.com>
Re: Stuffing @users into $self->{'users'} <peter@makholm.net>
Re: Stuffing @users into $self->{'users'} <peter@makholm.net>
Re: Stuffing @users into $self->{'users'} <Phillip.Ross.Taylor@gmail.com>
Re: Stuffing @users into $self->{'users'} <simon.chao@fmr.com>
Re: Stuffing @users into $self->{'users'} <john@castleamber.com>
Re: Will Perl 6 be usable as a procedure language? <allergic-to-spam@no-spam-allowed.org>
Re: Will Perl 6 be usable as a procedure language? (Ben Bullock)
Re: Will Perl 6 be usable as a procedure language? <usenet@larseighner.com>
Re: Will Perl 6 be usable as a procedure language? <rvtol+news@isolution.nl>
Re: Will Perl 6 be usable as a procedure language? <Peter@PSDT.com>
Re: Will Perl 6 be usable as a procedure language? <simon.chao@fmr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 2 May 2008 04:15:51 -0700 (PDT)
From: "dn.perl@gmail.com" <dn.perl@gmail.com>
Subject: Deeper level of hashing
Message-Id: <27d28e4f-6a24-4774-9085-5e87a1da4af0@l17g2000pri.googlegroups.com>
I am using (roughly) the following code.
my %counter = () ;
$counter{label11}{parent} = 'label1' ;
$counter{label11}{hits} = 14 ;
$counter{label12}{parent} = 'label1' ;
$counter{label12}{hits} = 14 ;
If I use: for my $key(keys %counter), I get label11 and label12 as
values.
I would like to run something like: foreach my $key(keys %
($counter(label11) ) )
and get 'parent' and 'hits' as the sub-keys.
Is there any quick way to do this but quicker than what? So let's say
is there a 'standard way' in which this is done? Or do I have to do it
the 'hard way' ? Define a sub-hash, and then assign it to the parent
hash as its key's value?
------------------------------
Date: Fri, 02 May 2008 13:23:33 +0200
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Deeper level of hashing
Message-Id: <87r6clne4q.fsf@zeekat.nl>
"dn.perl@gmail.com" <dn.perl@gmail.com> writes:
> I am using (roughly) the following code.
>
> my %counter = () ;
>
> $counter{label11}{parent} = 'label1' ;
> $counter{label11}{hits} = 14 ;
> $counter{label12}{parent} = 'label1' ;
> $counter{label12}{hits} = 14 ;
>
> If I use: for my $key(keys %counter), I get label11 and label12 as
> values.
> I would like to run something like: foreach my $key(keys %
> ($counter(label11) ) )
> and get 'parent' and 'hits' as the sub-keys.
>
> Is there any quick way to do this but quicker than what? So let's say
> is there a 'standard way' in which this is done? Or do I have to do it
> the 'hard way' ? Define a sub-hash, and then assign it to the parent
> hash as its key's value?
Do you mean something like this?
foreach my $key (keys %{$counter{label11}}) {
print "$key => $counter{label11}->{$key}\n";
}
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
------------------------------
Date: Fri, 02 May 2008 14:48:28 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Help: Reverse Letters
Message-Id: <t8am14hn0ma6h058vhofnbgkhvc8irm8f6@4ax.com>
Amy Lee <openlinuxsource@gmail.com> wrote:
>There's a problem while I'm processing sequences. My file content.
>ATGCCCTGACGTAAACGTAGGCTACG
>And I hope I can reverse the sequences to be this.
>GCATCGGATGCAAATGCAGTCCCGTA
You asked a self answering question: The reverse() function does exactly
that.
>I use "reverse" to do this, but it dose not work any more.
?????
Are you saying that coming back into the office after yesterday's Labour
Day the functionality of reverse() in Perl has changed?
jue
------------------------------
Date: Fri, 02 May 2008 15:52:55 +0100
From: RedGrittyBrick <RedGrittyBrick@SpamWeary.foo>
Subject: Re: Help: Reverse Letters
Message-Id: <481b2ac9$0$10647$fa0fcedb@news.zen.co.uk>
Amy Lee wrote:
> Hello,
>
> There's a problem while I'm processing sequences. My file content.
>
>> seq1
> ATGCCCTGACGTAAACGTAGGCTACG
>> seq2
> GCATGCCCTACGGGTACCCCAGTA
>
> And I hope I can reverse the sequences to be this.
>
>> seq1
> GCATCGGATGCAAATGCAGTCCCGTA
>> seq2
> ATGACCCCATGGGCATCCCGTACG
>
> I use "reverse" to do this, but it dose not work any more.
> So could you tell me how to solve this problem?
>
reverse needs a list
$ perl -e '$x="GCAT";$y=join"",reverse(split "",$x);print"$y\n"'
TACG
doubtless there are better ways to do this.
--
RGB
------------------------------
Date: Fri, 02 May 2008 15:55:40 +0100
From: RedGrittyBrick <RedGrittyBrick@SpamWeary.foo>
Subject: Re: Help: Reverse Letters
Message-Id: <481b2b6d$0$10647$fa0fcedb@news.zen.co.uk>
RedGrittyBrick wrote:
> Amy Lee wrote:
>> Hello,
>>
>> There's a problem while I'm processing sequences. My file content.
>>
>>> seq1
>> ATGCCCTGACGTAAACGTAGGCTACG
>>> seq2
>> GCATGCCCTACGGGTACCCCAGTA
>>
>> And I hope I can reverse the sequences to be this.
>>
>>> seq1
>> GCATCGGATGCAAATGCAGTCCCGTA
>>> seq2
>> ATGACCCCATGGGCATCCCGTACG
>>
>> I use "reverse" to do this, but it dose not work any more.
>> So could you tell me how to solve this problem?
>>
>
> reverse needs a list
>
> $ perl -e '$x="GCAT";$y=join"",reverse(split "",$x);print"$y\n"'
> TACG
>
Oh no it doesn't! How embarassing.
perl -e '$x="GCAT";$y=reverse($x);print"$y\n"'
TACG
--
RGB
------------------------------
Date: Fri, 02 May 2008 05:03:59 -0400
From: George Neuner <gneuner2/@/comcast.net>
Subject: Re: Python's doc problems: sort
Message-Id: <h1ml14tsjh4dgd3dd097fnc0d7sqod1dge@4ax.com>
On Wed, 30 Apr 2008 12:35:10 +0200, "John Thingstad"
<jpthing@online.no> wrote:
>På Wed, 30 Apr 2008 06:26:31 +0200, skrev George Sakkis
><george.sakkis@gmail.com>:
>
>>
>> \|||/
>> (o o)
>> ,----ooO--(_)-------.
>> | Please |
>> | don't feed the |
>> | TROLL's ! |
>> '--------------Ooo--'
>> |__|__|
>> || ||
>> ooO Ooo
>
>Doesn't copying Rainer Joswig's troll warning constitute a copywright
>infrigment :)
It's not an exact copy of Rainer's so it may be arguable whether it
violates his copyright. Might have more luck with a trademark
argument - distorted marks may still infringe.
George
--
for email reply remove "/" from address
------------------------------
Date: Fri, 2 May 2008 04:14:16 -0700 (PDT)
From: Philluminati <Phillip.Ross.Taylor@gmail.com>
Subject: Re: Stuffing @users into $self->{'users'}
Message-Id: <be15dd31-b783-4b54-91f9-c20069c3ffa5@y38g2000hsy.googlegroups.com>
With the exception of Sinan, I have had absolutely no help yet. Since
this is a prototype; emails about the structure of the code are
frankly meaningless. I don't need an adduser function because I don't
plan on adding users. That code is merely a placeholder for database
access code. Comments about what I do or do not know about Perl are
basically meaningless as well. I don't claim to be an expert in Perl.
That's why I am here asking a very simple question. Call it fumbling
with different attempts at the syntax but basically that's the real
problem I'm having. I only need something that works and I wanted to
show people that I have actually tried to solve this on my own before
I came here.
I need to see if this language is feasible as a SOAP Server, even
though there is little support in Perl's weakly typed language to
generate WSDL files automatically compared to Java, C/C++, .NET and
most other languages. You can't honestly expect me to read 900 pages
just for a small sample. If I wanted to try out in 4 languages I'd
basically have to read 3600 pages. **It only has to work**, it doesn't
have to work well. I just want to see how complicated it's going to
be. I already have a soap sample working but I now I want to extend it
with instances of objects and this is where it's all going wrong. The
objects aren't being remembered across the session - or at least
that's what I think.
When I test user_management.pm with my test script. The output is what
I expect. When I try to use it in soap I get this:
http://bayimg.com/bAjpCAabi
When I take out the line that says "use strict" I get this:
http://bayimg.com/BaJpDaAbi
perhaps I can be forgiven for actually "closing my eyes" since it only
happens in the SOAP client -> Soap Server example and it doesn't
happen when I run a test script directly against user_management.pm.
---
I think the function returns "0 of 0" because the class variables are
not being remembered. That's my feeling and that's the question I was
looking to solve but apparently I have been branded as ignorant
because I wanted to postpone reading a book until after I solved it.
The fact I have constructed an existing SOAP Server example, have
already demonstrated a considerable knowledge for someone who hasn't
yet read a book doesn't seem to count for anything. There seems to be
an invisible threshold of questions. The simpler the question the more
is warrants abuse from a developer's misunderstanding of the
fundamentals.
Anyway I have posted the code below and I really hope someone can help
me.
------------ USER.PM -------------
#!/usr/bin/perl -w
use strict;
package user;
sub new
{
my ($class_name) = @_;
my ($self) = {};
#warn "We just created our new variable...\n ";
bless ($self, $class_name);
#warn "and now it's a $class_name object!\n";
#$self->{'_created'} = 1;
return $self;
}
sub getId
{
my $self = shift;
return $self->{'id'};
}
sub setId
{
my ($self, $id) = @_;
$self->{'id'} = $id;
}
sub getUsername
{
my $self = shift;
return $self->{'username'};
}
sub setUsername
{
my ($self, $username) = @_;
$self->{'username'} = $username;
}
sub getPassword
{
my $self = shift;
return $self->{'password'};
}
sub setPassword
{
my ($self, $password) = @_;
$self->{'password'} = $password;
}
sub getSessionKey
{
my $self = shift;
return $self->{'sessionkey'};
}
sub setSessionKey
{
my ($self, $key) = @_;
$self->{'sessionkey'} = $key;
}
1;
-------- USER_MANAGEMENT.PM ------------------
#!/usr/bin/perl -w
package user_management;
use user;
use strict;
#my $instance = new user_management;
sub new
{
my ($class_name) = @_;
my ($self) = {};
bless ($self, $class_name);
#some objects for the array
my $phill = new user;
$phill->setId(6);
$phill->setUsername("ptaylor");
$phill->setPassword("password");
$phill->setSessionKey("");
my $simon = new user;
$simon->setId(7);
$simon->setUsername("sroberts");
$simon->setPassword("cheese");
$simon->setSessionKey("");
my $nick = new user;
$nick->setId(8);
$nick->setUsername("nick");
$nick->setPassword("rock");
$nick->setSessionKey("");
#put them in the array
my @users = ( $phill, $simon, $nick );
$self->{users} = \@users; #put the array in an instance variable (or
perl equiv)
$self->{nextSessionId} = ":-0";
return $self;
}
sub login
{
my ($self, $username, $password) = @_;
my @users = @{ $self->{users} };
foreach my $user (@users)
{
if ($user->getUsername() eq $username)
{
if ($user->getPassword() eq $password)
{
if ($user->getSessionKey ne "")
{
return "ERR: User already logged in";
}
else
{
#generate session key
$user->setSessionKey("SESS" . $self->{'nextSessionId'});
$self->{'nextSessionId'} = $self->{'nextSessionId'} + 1;
return $user->getSessionKey();
}
}
else
{ return "ERR: Password is wrong"; }
}
}
return "ERR: No users";
}
sub query
{
my $self = shift;
#return "Session id= " . $self->{nextSessionId} . "\n";
my @users = @{$self->{users}};
my $active = 0;
my $total = @users;
my $retval = "";
#return "Total: $total\n";
foreach my $usr (@users)
{
bless($usr, "user");
if ($usr->getSessionKey() ne "")
{
$retval = $retval . "user " . $usr->getUsername() . " logged in\n";
$active++;
}
else
{
$retval = $retval . "user " . $usr->getUsername() . " logged out
\n";
}
}
return "$retval$active of $total";
}
sub logout
{
my ($self, $sessionKey) = @_;
my @users = @{ $self->{users} };
foreach my $usr (@users)
{
if ($usr->getSessionKey() eq $sessionKey)
{
$usr->setSessionKey("");
return 1;
}
}
return 0;
}
1;
------------ TEST_USER.PL ----------------------------------
#!/usr/bin/perl -w
#THIS SCRIPT TESTS THAT USER_MANAGEMENT.PM WORKS CORRECTLY
#IT DOES WORK CORRECT ACCORDING TO THIS SCRIPT!
use user;
use user_management;
use strict;
print "code started\n";
my $phill1 = new user;
$phill1->setId(6);
$phill1->setUsername("phill");
$phill1->setPassword("hello");
my $dave1 = new user;
$dave1->setId(7);
$dave1->setUsername("dave");
$dave1->setPassword("omg");
my $alan1 = new user;
$alan1->setId(8);
$alan1->setUsername("alan");
$alan1->setPassword("alsecret");
my @users = ( $phill1, $alan1, $dave1 );
foreach my $currentUser (@users)
{
print "user id:\t" . $currentUser->getId() . "\n";
print "username:\t" . $currentUser->getUsername() . "\n";
print "password:\t" . $currentUser->getPassword() . "\n";
}
print "done\n";
#&load;
my $sessionKey = login("ptaylor","password");
print $sessionKey;
my $answer = &query;
print "$answer\n";
logout ($sessionKey);
$answer = &query;
print "$answer\n";
$sessionKey = login("nick","rock");
print "session key for nick is $sessionKey\n";
$answer = &query;
print "$answer\n";
print "done\n";
------------ USER_MANAGEMENT.CGI ----------------------
#!/usr/bin/perl -w
package user_management;
use user_management;
no warnings;
use SOAP::Transport::HTTP;
SOAP::Transport::HTTP::CGI
-> dispatch_to('user_management')
-> handle;
------------ THE WSDL FILE ----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="user_management"
targetNamespace="**textdeleted**"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="**textdeleted**"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<message name="loginParams">
<part name="username" type="xsd:string" />
<part name="password" type="xsd:string" />
</message>
<message name="loginRetval">
<part name="retval" type="xsd:string" />
</message>
<message name="void">
</message>
<message name="queryRetval">
<part name="retval" type="xsd:string" />
</message>
<message name="logoutParams">
<part name="sessionKey" type="xsd:string" />
</message>
<message name="logoutRetval">
<part name="retval" type="xsd:int" />
</message>
<portType name="user_management_port_type">
<operation name="login">
<input message="tns:loginParams" />
<output message="tns:loginRetval" />
</operation>
<operation name="query">
<input message="tns:void" />
<output message="tns:queryRetval" />
</operation>
<operation name="logout">
<input message="tns:logoutParams" />
<output message="tns:logoutRetval" />
</operation>
</portType>
<binding name="user_management_binding"
type="tns:user_management_port_type">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/
http" />
<operation name="login">
<soap:operation soapAction="urn:user_management#login" />
<input>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:user_management"
use="encoded" />
</input>
<output>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:user_management"
use="encoded" />
</output>
</operation>
<operation name="query">
<soap:operation soapAction="urn:user_management#query" />
<input>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:user_management"
use="encoded" />
</input>
<output>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:user_management"
use="encoded" />
</output>
</operation>
<operation name="logout">
<soap:operation soapAction="urn:user_management#logout" />
<input>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:user_management"
use="encoded" />
</input>
<output>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:user_management"
use="encoded" />
</output>
</operation>
</binding>
<service name="UserManagementService">
<documentation>Session Management for AM</documentation>
<port binding="tns:user_management_binding"
name="user_management_port">
<soap:address
location="**textdeleted**/user_management.cgi" />
</port>
</service>
</definitions>
-------------- THE SOAP CLIENT -------------------------
'consists of a textbox and a button of the window.
Imports SessionManagementExample.UserManagement
Public Class Form1
Private server As UserManagementService
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
server = New UserManagementService()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim answer As String = server.query()
TextBox1.Text = answer.Replace(Chr(10), vbCrLf)
End Sub
End Class
------------------------------------------------
Any help would be really appreciated. Thanks
------------------------------
Date: Fri, 02 May 2008 12:00:42 +0000
From: Peter Makholm <peter@makholm.net>
Subject: Re: Stuffing @users into $self->{'users'}
Message-Id: <87zlr8hq51.fsf@hacking.dk>
Philluminati <Phillip.Ross.Taylor@gmail.com> writes:
> ------------ USER_MANAGEMENT.CGI ----------------------
> #!/usr/bin/perl -w
>
> package user_management;
>
> use user_management;
> no warnings;
> use SOAP::Transport::HTTP;
>
> SOAP::Transport::HTTP::CGI
> -> dispatch_to('user_management')
> -> handle;
Nice, the SOAP and SOAP-Lite distributions uses the same package names
but with quite different documented API's, and you're using the
SOAP-Lite version it seems.
It is documented that you can use a module name as argument to
dispatch_to, but this doesn't mean that it instantiates an object and
calls the methods on this object. Instead it uses the methods as class
methods, in which case you $self variable will contain the class name
and not an instantiated object.
This is consistent with you seeing it complaining about trying to use
'user_magement' as a HASH ref, bacause this is what $self will be when
the methods is called as class methods.
A possible solution would be to have you cgi script say something
along the lines of:
#!/usr/bin/perl
use strict;
use warnings;
use user_management;
use SOAP::Transport::HTTP; # SOAP Lite module!!!
my $manager = user_management->new();
SOAP::Transport::HTTP::CGI->dispatch_to($manager)
->handle;
__END__
Even though this isn't quite as documented in SOAP::Transport::HTTP,
but see http://search.cpan.org/perldoc?SOAP::Server
//Makholm
------------------------------
Date: Fri, 02 May 2008 12:05:35 +0000
From: Peter Makholm <peter@makholm.net>
Subject: Re: Stuffing @users into $self->{'users'}
Message-Id: <87ve1whpww.fsf@hacking.dk>
Peter Makholm <peter@makholm.net> writes:
> Nice, the SOAP and SOAP-Lite distributions uses the same package names
> but with quite different documented API's, and you're using the
> SOAP-Lite version it seems.
The SOAP distribution seems unmaintained since september 2000 and
SOAP-Lite have lots of releases sinces this time.
//Makholm
------------------------------
Date: Fri, 2 May 2008 06:17:10 -0700 (PDT)
From: Philluminati <Phillip.Ross.Taylor@gmail.com>
Subject: Re: Stuffing @users into $self->{'users'}
Message-Id: <2163316f-0e48-468f-a249-e446922ae729@a70g2000hsh.googlegroups.com>
On May 2, 1:05 pm, Peter Makholm <pe...@makholm.net> wrote:
> Peter Makholm <pe...@makholm.net> writes:
> > Nice, the SOAP and SOAP-Lite distributions uses the same package names
> > but with quite different documented API's, and you're using the
> > SOAP-Lite version it seems.
>
> The SOAP distribution seems unmaintained since september 2000 and
> SOAP-Lite have lots of releases sinces this time.
>
> //Makholm
Oh wow it works perfectly.
Thank you Peter I really appreciate the time you've taken to answer my
post. :-)
------------------------------
Date: Fri, 2 May 2008 06:30:51 -0700 (PDT)
From: nolo contendere <simon.chao@fmr.com>
Subject: Re: Stuffing @users into $self->{'users'}
Message-Id: <1ad96e27-23c1-4e61-a5ab-fe572613c806@b1g2000hsg.googlegroups.com>
On May 2, 1:28=A0am, Sherman Pendley <spamt...@dot-app.org> wrote:
> "szr" <sz...@szromanMO.comVE> writes:
> > A. Sinan Unur wrote:
> >> Philluminati <Phillip.Ross.Tay...@gmail.com> wrote in news:661262f3-
> >> aea5-4734-906e-7062d77f2...@m44g2000hsc.googlegroups.com:
>
> >>> my @users =3D ref $self->{'users'}; //same message as above
> >>> my @users =3D @$self->{'users'};
> >>> my @users =3D \$self->{'users'};
> >>> my @users =3D map $self->{'users'}; =A0//gave 500 internal server err
> >>> my @users =3D ( $self->{'users'} ); //same as original err
> >>> my @users =3D scalar $self->{'users'};
>
> >> You are ignoring the fact that programming is a deterministic
> >> endeavor. Successful programmers are not those who throw a bazillion
> >> variations at a wall and see what sticks.
>
> > Isn't also about trial and error? Especially, but not limited to, people=
> > who are young in this field of study? How does one learn something if
> > they do not run some tests?
>
> Throwing a bunch of random gibberish at the compiler will eventually give
> you a result that "works," in the same sense that infinite monkeys with ty=
pe-
> writers will eventually produce Shakespeare. But the process will leave yo=
u
> none the wiser as to *how* it works, or *why* the other attempts failed.
> As a student learning a new language, the understanding of "how" and "why"=
> is as important, or more so, than a working finished program.
>
> Yes, at some point you have to write something and try it. But, before you=
> get to there, you should have an idea of what you expect the code to do. I=
f
> the results are as you expect, all is well and good. If not, then you need=
> to examine the code again, break it down into its components, and figure
> out which of those parts is not behaving how you expected it to - and then=
> change your expectations accordingly.
>
it's called heuristics.
------------------------------
Date: 2 May 2008 15:08:53 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Stuffing @users into $self->{'users'}
Message-Id: <Xns9A92673CB6CEFcastleamber@130.133.1.4>
"szr" <szrRE@szromanMO.comVE> wrote:
> A. Sinan Unur wrote:
>> Philluminati <Phillip.Ross.Taylor@gmail.com> wrote in news:661262f3-
>> aea5-4734-906e-7062d77f201f@m44g2000hsc.googlegroups.com:
>>
>>> my @users = ref $self->{'users'}; //same message as above
>>> my @users = @$self->{'users'};
>>> my @users = \$self->{'users'};
>>> my @users = map $self->{'users'}; //gave 500 internal server err
>>> my @users = ( $self->{'users'} ); //same as original err
>>> my @users = scalar $self->{'users'};
>>
>> You are ignoring the fact that programming is a deterministic
>> endeavor. Successful programmers are not those who throw a bazillion
>> variations at a wall and see what sticks.
>
> Isn't also about trial and error? Especially, but not limited to,
> people who are young in this field of study? How does one learn
> something if they do not run some tests?
A test, or maybe better: an experiment, is not the same as
adding/removing code until it works. It's understanding each ingredient
because you have studied the documentation, and it's having an
expectation of the outcome, and the code is to verify if your
understanding of the documentation is corrent.
Trial and error (try all and error), is often: put a book on your lap
(or nowadays open a browser), find a snippet of code that seems right,
and start modifying it until it works.
Somehow people think that actually reading a book has nothing to do with
programming (or that it's the long road), that programming is pressing
keys and nothing else. And no, I am not talking about managers.
But some people claim they can't read a book, and/or that they are more
practical and/or that their "way" works faster. They somehow forget that
people who are practical, for example a carpenter, don't trial and
error. A carpenter is not going to cut wood up into pieces and trying
all possible ways to stick them together in order to make a table. Such
a carpenter wood run out of resources very fast.
But somehow, as a "programmer" you're only wasting time, so it's harder
to detect, especially if the "programmer" is pushing keys the whole day.
( They also forget that it's quite hard to remember the solution if it
was found by trying a lot of possibilities. The next time they have a
similar problem they only vaguely remember what they did the last time,
and have to start somewhere at the beginning, modifying code again. )
> That is more or less how I advanced so deep
> into programming many moons ago, trying to see if this works,
You could have read that in the documentation. Something works or it
doesn't. There is no sometimes.
> what this
> that do, what happens if I do this, etc. Albeit, one should keep
> documentation close by too, but trial and error *is* a as big a part
> as anything IMHO.
It sounds to me that you talk more about what I call experimentation.
Trial and error is banging your head against the wall without having
read that there is a better tool to make a hole into it.
What's so sad, nowadays, is a lot of code discovered that way ends up on
the Internet, and is copied by trial and error programmers...
( I have similar feelings about people grabbing for a debugger for each
and every problem. I once worked on a project in a company, using C, and
each and every time there was a problem the way of action was to fire up
a debugger and single step throught the code.).
--
John
http://johnbokma.com/
------------------------------
Date: Fri, 2 May 2008 09:40:50 +0200 (CEST)
From: Jim Cochrane <allergic-to-spam@no-spam-allowed.org>
Subject: Re: Will Perl 6 be usable as a procedure language?
Message-Id: <slrng1lhc2.97n.allergic-to-spam@no-spam-allowed.org>
On 2008-05-02, Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "s" == szr <szrRE@szromanMO.comVE> writes:
>
> s> Peter Scott wrote:
> s> [...]
> >> Are you thinking that Perl 6 is intended to be backwards compatible
> >> with Perl 5? It isn't, and it won't be.
>
> s> While Perl 6 has it's merits, this alone doesn't really inspire me to an
> s> all out switch when it finally comes, and given how much code would be
> s> broken, I wouldn't be surprised if it ends up having a poor adoption
> s> rate for the first year or two because of this, as Perl 5.10 adds some
> s> of the Perl 6-destined features (like given/when) and still promotes
> s> backwards compatibility (and in a very intelligent and un-intrusive way)
> s> and future releases are likely to only be better.
>
> s> So given this, why would one, who have plenty of Perl code, feel
> s> compelled to choose Perl 6 over Perl 5 and spend what could huge amounts
> s> of time rewriting a lot of code?
>
> you should move this thread to the perl6 language list. but in any case
> p6 will have a p5 compiler in it (or some way to do that). larry's
> intent is that almost all p5 code could be compiled to run on the p6
> backend and so allow p5 and p6 code to run in the same process. this is
> better than backwards compatibility as it allows incremental migration
> of p5 code to p6 (and this may include tools to do that
> translation). the albatross of true backwards compatibility is what has
> kept x86 and redmond so 'backwards' for decades. supporting easy and
> clean migration to a new target is much smarter.
>
> as for prodedural vs OO, p6 will allow both but OO will be much stronger
> and such than p5's OO. look around for damian's slide show of p5 code vs
> the equivilent p6 code. much of the basic stuff won't change or will
> change little. there will still be scalars, arrays, hashes and
> subs. subs will have a proper arg passing and handling mechanism but the
> @_ style can be used in some way if desired. but the overall lang is so
> much better in p6 and sections suchs as rules/grammars vs p5 regexes are
> like comparing an orange grove to a crabapple. that change alone is
> worth using p6. read about that on the perl.org pages and look for the
> synopsis or other docs on p6 grammars.
>
> uri
>
It sounds to me like one could think of perl 6 as a different language
(which happens to have a very similar name) than perl 5, but with features
(described above) for compatibility with this other language (perl 5).
So perhaps it's helpful to think of p6 as a different language altogether,
designed in such a way as to be easily learnable by perl 5 programmers,
but whose design is better (especially in making it easier to use OO
features) than perl 5. In other words, switching to p6 would be a
language change (not a language/compiler/version upgrade) - similar to
switching from C++ to Java, although the difference would not be as large.
That's how I'm currently thinking of it, anyway.
Why would people want to make that change? Well, perhaps for similar
reasons that many people/organizations switched from C++ to Java?
(E.g., better productivity, maintainability, etc.)
--
------------------------------
Date: Fri, 2 May 2008 08:22:09 +0000 (UTC)
From: benkasminbullock@gmail.com (Ben Bullock)
Subject: Re: Will Perl 6 be usable as a procedure language?
Message-Id: <fveivh$drm$1@ml.accsnet.ne.jp>
Uri Guttman <uri@stemsystems.com> wrote:
> the albatross of true backwards compatibility is what has
> kept x86 and redmond so 'backwards' for decades.
But backwards-compatibility-albatross-less Perl 6 has been under
development for eight years, which is getting on for one decade.
------------------------------
Date: Fri, 02 May 2008 06:39:01 -0500
From: Lars Eighner <usenet@larseighner.com>
Subject: Re: Will Perl 6 be usable as a procedure language?
Message-Id: <slrng1lv6d.73l.usenet@debranded.larseighner.com>
In our last episode, <slrng1lhc2.97n.allergic-to-spam@no-spam-allowed.org>,
the lovely and talented Jim Cochrane broadcast on comp.lang.perl.misc:
> Why would people want to make that change? Well, perhaps for similar
> reasons that many people/organizations switched from C++ to Java?
> (E.g., better productivity, maintainability, etc.)
I'm not sure I have a choice. Development of my OS goes at a fearsome pace,
and if I wait too long, I will end up with an orphaned system. Soon or
later the OS will move to Perl 6. And sooner or later I will have to
upgrade to maintain the ability to install applications (easily). Meanwhile
I have tons of stuff in Perl (much of it original to avoid OO modules).
If Perl 6 will lock me in to OO, then I need to start rewriting the perl in
shell scripts (sed, awk, etc.) now.
--
Lars Eighner <http://larseighner.com/> usenet@larseighner.com
Countdown: 263 days to go.
------------------------------
Date: Fri, 2 May 2008 14:25:53 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Will Perl 6 be usable as a procedure language?
Message-Id: <fvf8ei.1cc.1@news.isolution.nl>
Lars Eighner schreef:
> Jim Cochrane:
>> Why would people want to make that change? Well, perhaps for similar
>> reasons that many people/organizations switched from C++ to Java?
>> (E.g., better productivity, maintainability, etc.)
>
> I'm not sure I have a choice. Development of my OS goes at a
> fearsome pace, and if I wait too long, I will end up with an orphaned
> system. Soon or later the OS will move to Perl 6. And sooner or
> later I will have to upgrade to maintain the ability to install
> applications (easily). Meanwhile I have tons of stuff in Perl (much
> of it original to avoid OO modules).
> If Perl 6 will lock me in to OO, then I need to start rewriting the
> perl in shell scripts (sed, awk, etc.) now.
No problem, C coexists to C++ as Perl 5 will coexist to Perl 6.
Perl 6 is a different language, Onion was coined as a better name for
it.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Fri, 02 May 2008 13:07:21 GMT
From: Peter Scott <Peter@PSDT.com>
Subject: Re: Will Perl 6 be usable as a procedure language?
Message-Id: <pan.2008.05.02.13.03.39.448509@PSDT.com>
On Fri, 02 May 2008 14:25:53 +0200, Dr.Ruud wrote:
> Perl 6 is a different language, Onion was coined as a better name for
> it.
Actually, 'Rakudo' is the accepted alternate moniker (referring to Perl 6
running on Parrot).
--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/
------------------------------
Date: Fri, 2 May 2008 06:26:53 -0700 (PDT)
From: nolo contendere <simon.chao@fmr.com>
Subject: Re: Will Perl 6 be usable as a procedure language?
Message-Id: <e7190a4e-abd0-4506-bd42-f72a7b6ee339@c58g2000hsc.googlegroups.com>
On May 1, 5:13=A0pm, Lars Eighner <use...@larseighner.com> wrote:
> In our last episode,
> <bb9e4723-a2d9-4517-bdfb-aa7371528...@r66g2000hsg.googlegroups.com>, the
> lovely and talented nolo contendere broadcast on comp.lang.perl.misc:
>
> > On May 1, 1:40=A0pm, xhos...@gmail.com wrote:
> >> nolo contendere <simon.c...@fmr.com> wrote:
> >> > On May 1, 1:12=3DA0am, Lars Eighner <use...@larseighner.com> wrote:
> >> > > Will perl 6 be usable as a procedure language?
>
> >> > What _exactly_ do you mean by 'procedure language'?
>
> >> I think he means "Not object oriented"
> > But can't one author code either procedurally or OO in the same
> > language?
>
> In some languages, yes (for example perl 5). In other, e.g. Java, not in a=
ny
> practical sense.
>
> > (This may not be the authority, but):
> > "The most popular programming languages usually have both OOP and
> > procedural aspects."
> >http://en.wikipedia.org/wiki/Procedural_programming#Comparison_with_o...
> > Perhaps the most popular language used for OOP is Java, but you can
> > write procedural code in Java if you wanted, correct?
>
> Not really.
>
> > I was hoping that the OP could list the exact criteria he was using for
> > determining the answer to his question.
>
> Can you write code without objects, object wrappers, etc. and use function=
s
> and subroutines instead? =A0Can you make function calls without object-lik=
e
> notation (i.e. little arrows made of hyphens and inequality signs pointing=
> in counter-intuitive directions)? =A0Are you bound to use some basic set o=
f
> objects which don't do what you want and you cannot edit? =A0Will it be
> incredibly slow and inefficient?
>
Consider Python--an OO Language ("Python is a dynamic object-oriented
programming language" from http://www.python.org/), everything is an
object. But, it is considered a procedural language as well.
http://en.wikipedia.org/wiki/Procedural_programming#Procedural_programming_l=
anguages
Python is roughly the same speed as Perl.
http://shootout.alioth.debian.org/gp4/benchmark.php?test=3Dall&lang=3Dperl&l=
ang2=3Dpython
Procedural programming is more of a style than a stricture of the
language.
Who really cares about the syntactic difference between a function
call and a method invocation? They amount to the same thing.
------------------------------
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 1503
***************************************