wrote-only language?

wrote-only language?

am 23.04.2008 07:03:51 von peng.kyo

Someone said Perl is a "wrote-only language", what does this mean?

--
J. Peng - QQMail Operation Team
eMail: peng.kyo@gmail.com AIM: JeffHua

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: wrote-only language?

am 23.04.2008 18:43:53 von Rob Dixon

J. Peng wrote:
>
> Someone said Perl is a "wrote-only language", what does this mean?

http://en.wikipedia.org/wiki/Write-only_language

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: wrote-only language?

am 23.04.2008 18:46:41 von chas.owens

On Wed, Apr 23, 2008 at 1:03 AM, J. Peng wrote:
> Someone said Perl is a "wrote-only language", what does this mean?
snip

Normally it is write-only language. This refers to some people's
belief that Perl is difficult to read. That is, you can write it but
you can't read it afterward. The problem with this semi-humorous
statement is that it applies to all languages, not just Perl.
Properly written, Perl is just as readable as any other (properly
written) language.

--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

going through array of hash, it only goes through limited amountof keys while doing for each command

am 23.04.2008 19:23:50 von Richard Lee

something is wrong with this..

say %yahoo's key contains the variable , X

I wanted to go through the @array which has array of hashes... to see if
one of the value is equal to
X and if it is, wanted to assign the key of the @array to $ex_var..

Tracing the program, it only goes through 6 lines of keys in @t_array
(random keys) (it has 89 keys total).. what am i doing wrong?




while (my ($keys,$values) = each(%yahoo) ) {
no strict 'refs';
MF: for my $i (0 .. $#t_array) {
for ( my($k,$v) = each(%{ $t_array[$i] } ) ) {
my $keys_b = qr/$keys/;
if ( $v =~ m/$keys_b/ ) {
$ex_var = $k;
last MF;
}
}
}

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: wrote-only language?

am 23.04.2008 19:27:45 von Octavian Rasnita

Perl is a write-only language because its main advantage "There is more than
one way to do it".

It is the most flexible language, so there can be very many styles of
programming in perl, and because of this it is much harder to create a big
team of programmers in perl than in other languages.
The members of a big team of perl programmers should be very good
programmers because they need to understand many styles of writing the code,
and this is harder, especially that there are much fewer perl programmers
than the number of programmers in other languages like Java, C#, or PHP.

Octavian

----- Original Message -----
From: "J. Peng"
To: "Perl beginners"
Sent: Wednesday, April 23, 2008 8:03 AM
Subject: wrote-only language?


> Someone said Perl is a "wrote-only language", what does this mean?
>
> --
> J. Peng - QQMail Operation Team
> eMail: peng.kyo@gmail.com AIM: JeffHua
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>
>


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: going through array of hash, it only goes through limited amountof keys while doing for each com

am 23.04.2008 20:16:39 von krahnj

Richard Lee wrote:
>
> something is wrong with this..
>
> say %yahoo's key contains the variable , X
>
> I wanted to go through the @array which has array of hashes... to see if
> one of the value is equal to
> X and if it is, wanted to assign the key of the @array to $ex_var..
>
> Tracing the program, it only goes through 6 lines of keys in @t_array
> (random keys) (it has 89 keys total).. what am i doing wrong?
>
>
>
>
> while (my ($keys,$values) = each(%yahoo) ) {
> no strict 'refs';
> MF: for my $i (0 .. $#t_array) {
> for ( my($k,$v) = each(%{ $t_array[$i] } ) ) {

The for loop is not doing what you appear to think it is supposed to be
doing:

$ perl -le'
my %hash = "A" .. "Z";
for my $c ( 1 .. 3 ) {
my $i;
for ( my ( $k, $v ) = each %hash ) {
print "$c ", ++$i, qq[: \$_ = "$_" \$k = "$k" \$v = "$v"];
}
}
'
1 1: $_ = "S" $k = "S" $v = "T"
1 2: $_ = "T" $k = "S" $v = "T"
2 1: $_ = "A" $k = "A" $v = "B"
2 2: $_ = "B" $k = "A" $v = "B"
3 1: $_ = "O" $k = "O" $v = "P"
3 2: $_ = "P" $k = "O" $v = "P"


You need to use each() in a while loop instead.


> my $keys_b = qr/$keys/;
> if ( $v =~ m/$keys_b/ ) {
> $ex_var = $k;
> last MF;
> }
> }
> }


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: going through array of hash, it only goes through limited amountof keys while doing for each com

am 23.04.2008 20:55:31 von Richard Lee

John W. Krahn wrote:
> Richard Lee wrote:
>>
>> something is wrong with this..
>>
>> say %yahoo's key contains the variable , X
>>
>> I wanted to go through the @array which has array of hashes... to see
>> if one of the value is equal to
>> X and if it is, wanted to assign the key of the @array to $ex_var..
>>
>> Tracing the program, it only goes through 6 lines of keys in @t_array
>> (random keys) (it has 89 keys total).. what am i doing wrong?
>>
>>
>>
>>
>> while (my ($keys,$values) = each(%yahoo) ) {
>> no strict 'refs';
>> MF: for my $i (0 .. $#t_array) {
>> for ( my($k,$v) = each(%{ $t_array[$i] } ) ) {
>
> The for loop is not doing what you appear to think it is supposed to
> be doing:
>
> $ perl -le'
> my %hash = "A" .. "Z";
> for my $c ( 1 .. 3 ) {
> my $i;
> for ( my ( $k, $v ) = each %hash ) {
> print "$c ", ++$i, qq[: \$_ = "$_" \$k = "$k" \$v = "$v"];
> }
> }
> '
> 1 1: $_ = "S" $k = "S" $v = "T"
> 1 2: $_ = "T" $k = "S" $v = "T"
> 2 1: $_ = "A" $k = "A" $v = "B"
> 2 2: $_ = "B" $k = "A" $v = "B"
> 3 1: $_ = "O" $k = "O" $v = "P"
> 3 2: $_ = "P" $k = "O" $v = "P"
>
>
> You need to use each() in a while loop instead.
>
>
>> my $keys_b = qr/$keys/;
>> if ( $v =~ m/$keys_b/ ) {
>> $ex_var = $k;
>> last MF;
>> }
>> }
>> }
>
>
> John
but my hash that i am going over is


%a = ( 'something' => '1', 'something2' => '2');
%b = ( 'something' => '2', 'something3'=>3);

@array = (\%a, \%b)

so I am not sure how to use each ?

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: going through array of hash, it only goes through limited amountof keys while doing for each com

am 23.04.2008 21:04:45 von Richard Lee

John W. Krahn wrote:
> Richard Lee wrote:
>>
>> something is wrong with this..
>>
>> say %yahoo's key contains the variable , X
>>
>> I wanted to go through the @array which has array of hashes... to see
>> if one of the value is equal to
>> X and if it is, wanted to assign the key of the @array to $ex_var..
>>
>> Tracing the program, it only goes through 6 lines of keys in @t_array
>> (random keys) (it has 89 keys total).. what am i doing wrong?
>>
>>
>>
>>
>> while (my ($keys,$values) = each(%yahoo) ) {
>> no strict 'refs';
>> MF: for my $i (0 .. $#t_array) {
>> for ( my($k,$v) = each(%{ $t_array[$i] } ) ) {
>
> The for loop is not doing what you appear to think it is supposed to
> be doing:
>
> $ perl -le'
> my %hash = "A" .. "Z";
> for my $c ( 1 .. 3 ) {
> my $i;
> for ( my ( $k, $v ) = each %hash ) {
> print "$c ", ++$i, qq[: \$_ = "$_" \$k = "$k" \$v = "$v"];
> }
> }
> '
> 1 1: $_ = "S" $k = "S" $v = "T"
> 1 2: $_ = "T" $k = "S" $v = "T"
> 2 1: $_ = "A" $k = "A" $v = "B"
> 2 2: $_ = "B" $k = "A" $v = "B"
> 3 1: $_ = "O" $k = "O" $v = "P"
> 3 2: $_ = "P" $k = "O" $v = "P"
>
>
> You need to use each() in a while loop instead.
>
>
>> my $keys_b = qr/$keys/;
>> if ( $v =~ m/$keys_b/ ) {
>> $ex_var = $k;
>> last MF;
>> }
>> }
>> }
>
>
> John



while (my ($keys,$values) = each(%yahoo) ) {
no strict 'refs';
MF: for my $i (0 .. $#t_array) {
for ( my($k,$v) = each %{ $t_array[$i] } ) {
# for ( my($k,$v) = each %t_array ) {
my $keys_b = qr/$keys/;
if ( $v =~ m/$keys_b/ ) {
$ex_var = $k;
last MF;
}
}
}


while @t_array contains

%something = (
"something1" => "123",
"something2" => "234",
..... so and on
);

%something_now = (
"something11" => '123123',
"something222" => '2134',
)

@t_array = (\%something, \%someting_now)

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: wrote-only language?

am 24.04.2008 00:50:49 von Jenda Krynicky

From: "J. Peng"
> Someone said Perl is a "wrote-only language", what does this mean?

That the person can't spell and doesn't know Perl.

Jenda
===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: going through array of hash, it only goes through limited amountof keys while doing for each com

am 24.04.2008 03:21:06 von Richard Lee

John W. Krahn wrote:
> Richard Lee wrote:
>>
>> something is wrong with this..
>>
>> say %yahoo's key contains the variable , X
>>
>> I wanted to go through the @array which has array of hashes... to see
>> if one of the value is equal to
>> X and if it is, wanted to assign the key of the @array to $ex_var..
>>
>> Tracing the program, it only goes through 6 lines of keys in @t_array
>> (random keys) (it has 89 keys total).. what am i doing wrong?
>>
>>
>>
>>
>> while (my ($keys,$values) = each(%yahoo) ) {
>> no strict 'refs';
>> MF: for my $i (0 .. $#t_array) {
>> for ( my($k,$v) = each(%{ $t_array[$i] } ) ) {
>
> The for loop is not doing what you appear to think it is supposed to
> be doing:
>
> $ perl -le'
> my %hash = "A" .. "Z";
> for my $c ( 1 .. 3 ) {
> my $i;
> for ( my ( $k, $v ) = each %hash ) {
> print "$c ", ++$i, qq[: \$_ = "$_" \$k = "$k" \$v = "$v"];
> }
> }
> '
> 1 1: $_ = "S" $k = "S" $v = "T"
> 1 2: $_ = "T" $k = "S" $v = "T"
> 2 1: $_ = "A" $k = "A" $v = "B"
> 2 2: $_ = "B" $k = "A" $v = "B"
> 3 1: $_ = "O" $k = "O" $v = "P"
> 3 2: $_ = "P" $k = "O" $v = "P"
>
>
> You need to use each() in a while loop instead.
>
>
>> my $keys_b = qr/$keys/;
>> if ( $v =~ m/$keys_b/ ) {
>> $ex_var = $k;
>> last MF;
>> }
>> }
>> }
>
>
> John
It is funny why this is not producing what I thought it would..
I will continue to dig till I get this..

cat ././ref_each.pl
#!/usr/bin/perl

use warnings;
use strict;
use Data::Dumper;

my %yahoo = qw(
uno one
dos two
);

my %color = qw(
white 10
yellow 20
red 30
);

my @combine = ( \%yahoo, \%color );

print Dumper(@combine);


for ( 0 .. $#combine ) {
for ( my ($k, $v) = each(%{ $combine[$_] } ) ) {
print "\$k is $k\n";
print "\$v is $v\n";
}
}

../././ref_each.pl
$VAR1 = {
'uno' => 'one',
'dos' => 'two'
};
$VAR2 = {
'white' => '10',
'red' => '30',
'yellow' => '20'
};
$k is uno
$v is one
$k is uno
$v is one
$k is white
$v is 10
$k is white
$v is 10

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: going through array of hash, it only goes through limited amountof keys while doing for each com

am 24.04.2008 03:37:41 von Richard Lee

John W. Krahn wrote:
> Richard Lee wrote:
>>
>> something is wrong with this..
>>
>> say %yahoo's key contains the variable , X
>>
>> I wanted to go through the @array which has array of hashes... to see
>> if one of the value is equal to
>> X and if it is, wanted to assign the key of the @array to $ex_var..
>>
>> Tracing the program, it only goes through 6 lines of keys in @t_array
>> (random keys) (it has 89 keys total).. what am i doing wrong?
>>
>>
>>
>>
>> while (my ($keys,$values) = each(%yahoo) ) {
>> no strict 'refs';
>> MF: for my $i (0 .. $#t_array) {
>> for ( my($k,$v) = each(%{ $t_array[$i] } ) ) {
>
> The for loop is not doing what you appear to think it is supposed to
> be doing:
>
> $ perl -le'
> my %hash = "A" .. "Z";
> for my $c ( 1 .. 3 ) {
> my $i;
> for ( my ( $k, $v ) = each %hash ) {
> print "$c ", ++$i, qq[: \$_ = "$_" \$k = "$k" \$v = "$v"];
> }
> }
> '
> 1 1: $_ = "S" $k = "S" $v = "T"
> 1 2: $_ = "T" $k = "S" $v = "T"
> 2 1: $_ = "A" $k = "A" $v = "B"
> 2 2: $_ = "B" $k = "A" $v = "B"
> 3 1: $_ = "O" $k = "O" $v = "P"
> 3 2: $_ = "P" $k = "O" $v = "P"
>
>
> You need to use each() in a while loop instead.
>
>
>> my $keys_b = qr/$keys/;
>> if ( $v =~ m/$keys_b/ ) {
>> $ex_var = $k;
>> last MF;
>> }
>> }
>> }
>
>
> John

finally understood what you meant.. thanks!!

#!/usr/bin/perl

use warnings;
use strict;
use Data::Dumper;

my %yahoo = qw(
uno one
dos two
);

my %color = qw(
white 10
yellow 20
red 30
);

my @combine = ( \%yahoo, \%color );

print Dumper(@combine);


for my $href ( @combine ) {
while ( my ($k, $v) = each %$href ) {
#for my $keys ( keys %$href ) {
print "\$k is $k\n";
print "\$v is $v\n";
print "==========\n";
}
}


.././././././ref_each.pl
$VAR1 = {
'uno' => 'one',
'dos' => 'two'
};
$VAR2 = {
'white' => '10',
'red' => '30',
'yellow' => '20'
};
$k is uno
$v is one
==========
$k is dos
$v is two
==========
$k is white
$v is 10
==========
$k is red
$v is 30
==========
$k is yellow
$v is 20
==========


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/