Re: How to accumulate Hashes of Array value with the same key?

2004-10-01 Thread Edward Wijaya
On Thu, 30 Sep 2004 17:03:40 -0400, Dave Gray [EMAIL PROTECTED] wrote:
I'm not sure what you want to do here... do you want to combine all
the values into one array reference, stored in $HoA{key1}?
As you mention above. That is exactly what I mean:
This sounds like it's part of a bigger question. Can you give us some
more background info?
What I am trying to do is to accumulate, every new HoA generated
into existing HoA, and join the values if they have the same key.
Dave

Regards,
Edward WIJAYA
SINGAPORE
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Nicolay A. Vasiliev
Hello!
This is very interesting thread. So, let me add some words to this. 
(Sorry in advance my English).

Best of all, let me express my respect to Mr. Schwartz. I read your 
Lama-book and I think that's very useful for every Perl newbie. I got 
such chain: Lama-book, Camel-book and Cook-book :).

I love Perl and work with it more often than Python, but...
Randal L. Schwartz wrote:
Gavin == Gavin Henry [EMAIL PROTECTED] writes:
   

Gavin I really like Perl, but lately everywhere I seem to go and talk
Gavin to say I shouldn't be learning Perl as it's old and Python is
Gavin better.
Perl is more powerful.  Python is simpler.  Python is for people
who don't want to master a language -- just use it casually.
 

This is no serious statement. Python is simple and power too. Read 
please Bruce Eckel why he left Perl and came to Python.
At least, it's really object-oriented as against Perl and it has more 
funny syntax :).

However, if you're gonna spend two or more hours a day hacking code,
Perl is definitely the right place to be.  Still.
Those Python weenies are all just casual programmers complaining
that for Perl, with great power comes great responsibility.  Let'em.
Perl's support only grows.  I used to be able to follow the CPAN new
modules list by examining the daily run at search.cpan.org/recent.
But no more.  Look at all the new modules just in the past *seven*
days.  (It's typically a full web page for each day!) If that doesn't
show you an intense activity in the Perl community, I really don't
know what else I could show you.
 

Python community is large too (of course not yet as perl community 
because it's more young), and it grows too. Let me know please why this 
is a good - such enormous modules number for one task? In this case I'd 
like to think noone from them is clever and bugs free. That's enough one 
or two clever modules like in Python, that even could be included into 
standart distribution.

Ask your Python friends where such a similar list exists. :)
Python may be newer, but Perl is more mature, and here to stay.
Remember new coke, and how long we had that. (If you're old enough
to remember that fiasco.)
 

--
Best regards,
Nicolay
http://www.soft411.com - Excellent soft archive
http://www.spamliquidator.com - Kill spam
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: How to accumulate Hashes of Array value with the same key?

2004-10-01 Thread Edward Wijaya
On Thu, 30 Sep 2004 14:23:47 -0300, Shaw, Matthew [EMAIL PROTECTED]
wrote:
Thanks Matt,

 my %HoA = (key1 = ['A',1]);
 my %HoA2 = (key1 = ['B',2]);
 my %HoA3 = (key1 = ['C',2]);

 into:

Only this one works
push @{$HoA{key1}}, ( @{$HoA2{key1}}, @{$HoA2{key1}});

Not this
Sorry this should read:
@{$HoA{key1}}, ( @{$HoA2{key1}}, @{$HoA3{key1}});
However what it gives is that it create one single array,
and not preserving the array that group ['A',1] etc, like before
namely:
print Dumper \%HoA;
$VAR1 = {
   'key1' = [
   'A',
   1,
   'B',
   2,
   'C',
   2
 ]
 };
not;
$VAR1 = { 'key1' = ['A',1],['B',2],['C',2]};
Regards,
Edward WIJAYA
SINGAPORE
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: modules

2004-10-01 Thread Sano Babu
[snip]
 If you want to do as the Romans do, maybe you can sign up for a Gmail
 account or something that would be more flexible...
Do u want to be one of the Romans? :-) Its hell good being Roman.. 
Amongst many other things just to name a few advantage of being Roman are
u almost never might need to delete messages and the contacts are
pretty easy to get around, short cut key etc.. 1000 mb to use as ur
own sec storage space. Its pretty good. I feel great! That pretty much
explains why Romans ruled this world once. :)
[snip]
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response
 
 



-- 
Cheers,
SanoBabu

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Sano Babu
 Perl is more powerful.  Python is simpler.  Python is for people
 who don't want to master a language -- just use it casually.
 
 
 This is no serious statement. Python is simple and power too. Read
 please Bruce Eckel why he left Perl and came to Python.
 At least, it's really object-oriented as against Perl and it has more
 funny syntax :).
 

Perl has OO support. In my opinion those funny syntax get u the job
done quicker when your boss comes down to you with deadly deadlines.
~;-) I assume those syntax u are talking about is regular expression.

 
 --
 Best regards,
 Nicolay
 
 http://www.soft411.com - Excellent soft archive
 http://www.spamliquidator.com - Kill spam

[snip]

-- 
Cheers,
SanoBabu

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: RFC on script

2004-10-01 Thread Charles K. Clarkson
From: RichT mailto:[EMAIL PROTECTED] wrote:

:  im still very new to perl and, iv got my script
: working,

It doesn't work for me. What are you using on the
command line to make it work? According to the usage shown
below, this script should fail every time.


: what is does in searches  through a large data file finds the
:  segments i need and outputs the data in a more use-full
: format. As i said id does work but im 
: no to convinced the structure is very clean
:  so i  thort maybe some one could give me some pointers.
: yours
: most gratefully RichT

First, I am going to piss off you or someone else on the
list. That's not my intent. It's is my experience. My intent is
to illustrate the errors in this script and the errors and
inconsistencies in your programming style. It, in no way is
meant to ridicule you or condemn your script.

Second, some corrections are stylistic. For example, the
one space indents for some foreach blocks don't make sense
with all other indents being four spaces. This is your style.
There nothing wrong with that (other than being
inconsistent). Your style will not always match mine.

Third, some errors are not errors. Some idioms are
more accepted than others. Not using strict or warnings on
a script sent to a mailing list is not really an error, but
it is a very bad idea.

Fourth, I am going to spend more time on the minuses
than on the plusses. Live with it.

Fifth, I'm not a big fan of mixed case variable names.
Any multiple word variables I add will use underscores. I
also hate parenthesies. I will quietly change them in
rewrites.

Last, my opinion is just that: my opinion. It is not
fact and you do not have to follow my advice. Some of it may
even be poor advice. Shop around and ask questions.


: scanPoller.cfg.pl==
: 
: #!/usr/local/bin/perl
: 
: use strict;
: use warnings;

Great start.

: use Getopt::Long;
: 
: my($inFile,$USAGE,$showKey,$site,$found,$foundKeys,
:@dataFile,@foundSegments,$value);
: my($opt_inFile, $opt_showAll, $opt_help ) = (0,0,0);

This is perl. It is not VB or C. Stop declaring your
variables at the top of your code block. It WILL bite you
in the ass. The rest of my comments will assume these were
not declared here.

Why is $USAGE in all caps?


: my $feildName = agentAddress;
: my $showFields = segment,agentAddress,community;

Line up those assignments and don't use double quotes
unless you're interpolating variables.

my $fieldname  = 'agentAddress';
my $showFields = 'segment,agentAddress,community';


: $USAGE = USAGE_TEXT;

my $usage = USAGE_TEXT;

[snipped info due to wrapping problems]
: USAGE_TEXT


: GetOptions (  inFile=s,
:   findFeild=s   = \$feildName,
:   showFeilds=s  = \$showFields,
:   showAll,
:   help|h|H|?|HELP
:   );

Field is spelled wrong. Get an editor that has a spell
checker.

Line things up and use single quotes over double quotes.
When I see double quotes, I assume you have data in there to
interpolate and I look for it. This slows me down. I assume
it will slow down another script maintainer as well.

We need to use global variables to use the above. Let's
avoid them here. 

GetOptions (
'inFile=s', = \$inFile,
'findField=s'   = \$fieldName,
'showFields=s'  = \$showFields,
'showAll'   = \$opt_showAll,
'help|h|H|?|HELP'   = \$opt_help,
);


: if ($opt_help == 1) {print $USAGE; exit; } # print out
 # help and
 # exit

Using trailing comments sparingly. Don't bunch up if
statements. Either use a statement modifier.

die $usage if $opt_help;

Or spell it out.

if ( $opt_help ) {
print $usage;
exit;
}

On my system (Windows XP) this doesn't work. $opt_help
always remains 0. This works.

use strict;
use warnings;
use Getopt::Long 'GetOptions';

my( $inFile, $showAll, $fieldName, $showFields );
{
$fieldName  = 'agentAddress';
$showFields = 'segment,agentAddress,community';

my $help
GetOptions(
'inFile=s', = \$inFile,
'findField=s'   = \$fieldName,
'showFields=s'  = \$showFields,
'showAll'   = \$showAll,
'help|h|H|?|HELP'   = \$help,
);

die usage() if $help;
}

sub usage {
return USAGE_TEXT;
usage: $0 [-inFile input filename] [-findField fieldName (default is
agentAddress)]
  [-showFields fields to output (default is
segment,agentAddress,community)] [-showAll show all fields]
  [-help this help text]
USAGE_TEXT
}

__END__


: # start finding results
: if ($inFile){  # find  results if we have in -inFile

Is the comment really needed? if ( $inFile )
pretty much says the same thing.

Note that in the original script $inFile is never set
to a value. This code block is never executed. Perhaps
we can see the stupidity in 

Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Nicolay A. Vasiliev
I mean real OO, but no perls dirty hack.
Perl has OO support. In my opinion those funny syntax get u the job
done quicker when your boss comes down to you with deadly deadlines.
~;-) I assume those syntax u are talking about is regular expression.
 

--
Best regards,
Nicolay
http://www.soft411.com - Excellent soft archive
http://www.spamliquidator.com - Kill spam
   

 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Gabor Urban
Hi guys,

this thread seems to expand into something unworthy of this mailing
list. You can not compare a cup of tea with a horse, these are two
totally different things.

Both Perl and Python have it's place under the sun, both have very good
features, and some very difficult aspects, too. Both can be perfect for
the right tasks, but may be terrible choices for others. THe real point
if you write your code correct, know what you are doing and make
possible for others to understand your source. The difference is between
good and poor developer. IMHO I could write this about any other
language, for example Cobol, too :-

I am doing Python programming for living now, but create reports on my
log useng Perl. Perfect, smooth and efficient.

Gabaux


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Nicolay A. Vasiliev
Agreed!
Gabor Urban wrote:
Hi guys,
this thread seems to expand into something unworthy of this mailing
list. You can not compare a cup of tea with a horse, these are two
totally different things.
Both Perl and Python have it's place under the sun, both have very good
features, and some very difficult aspects, too. Both can be perfect for
the right tasks, but may be terrible choices for others. THe real point
if you write your code correct, know what you are doing and make
possible for others to understand your source. The difference is between
good and poor developer. IMHO I could write this about any other
language, for example Cobol, too :-
I am doing Python programming for living now, but create reports on my
log useng Perl. Perfect, smooth and efficient.
Gabaux
 

http://www.soft411.com - Excellent soft archive
http://www.spamliquidator.com - Kill spam
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: Becoming Disenheartened - Everyone talks about Python and saysPerl is old news.

2004-10-01 Thread NYIMI Jose \(BMB\)


 -Original Message-
 From: Gabor Urban [mailto:[EMAIL PROTECTED] 
 Sent: Friday, October 01, 2004 11:05 AM
 To: [EMAIL PROTECTED]
 Subject: Re: Becoming Disenheartened - Everyone talks about 
 Python and saysPerl is old news.
 
 
 Hi guys,
 
 this thread seems to expand into something unworthy of this 
 mailing list. You can not compare a cup of tea with a horse, 
 these are two totally different things.
 
 Both Perl and Python have it's place under the sun, both have 
 very good features, and some very difficult aspects, too. 
 Both can be perfect for the right tasks, but may be terrible 
 choices for others. THe real point if you write your code 
 correct, know what you are doing and make possible for others 
 to understand your source. The difference is between good and 
 poor developer. IMHO I could write this about any other 
 language, for example Cobol, too :-
 
 I am doing Python programming for living now, but create 
 reports on my log useng Perl. Perfect, smooth and efficient.
 

Agreed as well !

Could you guys keep this thread constructive or STOP it ... Please ?

Thx,

José.


 DISCLAIMER 

This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer.

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Becoming Disenheartened - Everyone talks about Python and saysPerl is old news.

2004-10-01 Thread Gavin Henry
 Could you guys keep this thread constructive or STOP it ... Please ?


It's been very constructive for me :-)

I have just read this famous peice:

http://www.linuxjournal.com/article.php?sid=3882mode=order=thold=


I am going to learn both and make up my own mind. I think that's the best
for any hacker.

Gavin.


-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Becoming Disenheartened - Everyone talks about Python and saysPerl is old news.

2004-10-01 Thread Nicolay A. Vasiliev
Absolutely :)
Gavin Henry wrote:
Could you guys keep this thread constructive or STOP it ... Please ?
   

It's been very constructive for me :-)
I have just read this famous peice:
http://www.linuxjournal.com/article.php?sid=3882mode=order=thold=
I am going to learn both and make up my own mind. I think that's the best
for any hacker.
Gavin.
 

Best regards,
Nicolay
http://www.soft411.com - Excellent soft archive
http://www.spamliquidator.com - Kill spam
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: sum a column

2004-10-01 Thread Gunnar Hjalmarsson
Rmck wrote:
Are you serious.
Indeed.
Im not sure how to sum up the column... I tried by using the field
and * it by the increment.
That awkward attempt seems to be made by someone who hasn't a clue
about programming.
I have written every part of my script,
The script author does have a clue about programming.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Randal L. Schwartz
 Nicolay == Nicolay A Vasiliev [EMAIL PROTECTED] writes:

Nicolay I mean real OO, but no perls dirty hack.

There is nothing dirty or hack about Perl's OO.  It is as
functionally complete as nearly any other programming language.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: how do i describe a perl user?

2004-10-01 Thread Randal L. Schwartz
 Errin == Errin Larsen [EMAIL PROTECTED] writes:

Errin I say 'Perler' when I'm addressing this list.  Haven't had anyone
Errin complain yet!  I haven't seen anything else!  Anyone else have some
Errin suggestions?  The 'Guru's on the web are at a site called Perl
Errin Monks.  But what do you call a devotee, not a guru?

I've never heard of Perler (or seen you say it), and it sounds weird
to my ears.

Perl newbie
Perl user
Perl hacker

That would cover most of the spectrum.  Unless you're on P5P or P6-*,
in which case you are a:

perl hacker

Note lowercase p. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Check for valid email address

2004-10-01 Thread Randal L. Schwartz
 Gunnar == Gunnar Hjalmarsson [EMAIL PROTECTED] writes:

Gunnar Or: This is a function I'm using in a couple of programs to check the
Gunnar syntax, and that I believe is sufficient in practice:

Gunnar  sub emailsyntax {
Gunnar  return 1 unless
Gunnarmy ($localpart, $domain) = shift =~ /^(.+)@(.+)/;
Gunnar  my $char = '[^()@,;:\/\s\'|.]';
Gunnar  return 1 unless $localpart =~ /^$char+(?:\.$char+)*$/ or
Gunnar$localpart =~ /^[^,]+$/;
Gunnar  $domain =~ /^$char+(?:\.$char+)+$/ ? 0 : 1;
Gunnar  }

No, that incorrectly invalidates

fred[EMAIL PROTECTED]

which is a valid working address (try it!  it's an autoresponder).
Just use Email::Valid.  It has the right idea.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Becoming Disenheartened - Everyone talks about Python and saysPerl is old news.

2004-10-01 Thread Randal L. Schwartz
 Gavin == Gavin Henry [EMAIL PROTECTED] writes:

Gavin I have just read this famous peice:

Gavin http://www.linuxjournal.com/article.php?sid=3882mode=order=thold=

I'm pretty sure that Eric Raymond is not fully aware of
test-first-development and Test::More and proper module packaging of
Perl.  Otherwise, he wouldn't keep spouting his Perl sucks for big
projects mantra.

Perl's object model is complete.  Perl scales well to large projects.
That Eric Raymond was unable to get it to scale is more telling about
Eric than about Perl.

I say this even though I consider Eric at least a strong acquaintence,
having met him on quite a few occasions.  Eric is doing a disservice
to the Perl community though, and on that, I cannot let stand.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Nicolay A. Vasiliev
Dear mr. Schwartz!
Let me be unagreed. Functionally complete OO language at least means the 
next thing: when I create some object (ie, declare some variable, maybe 
string), this already have necessary methods like Python or Ruby. Even 
C++ haven't such functionality. Of course Perl haven't this too.

I love Perl, it's great for concrete tasks class. But Python is good and 
clever too, don't you blacken this please even in a comedy form ;)

Randal L. Schwartz wrote:
Nicolay == Nicolay A Vasiliev [EMAIL PROTECTED] writes:
   

Nicolay I mean real OO, but no perls dirty hack.
There is nothing dirty or hack about Perl's OO.  It is as
functionally complete as nearly any other programming language.
 

--
Best regards,
Nicolay
http://www.soft411.com - Excellent soft archive
http://www.spamliquidator.com - Kill spam
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Chris Devers
On Fri, 1 Oct 2004, Nicolay A. Vasiliev wrote:

 Functionally complete OO language at least means the next thing: when 
 I create some object (ie, declare some variable, maybe string), this 
 already have necessary methods like Python or Ruby. Even C++ haven't 
 such functionality. Of course Perl haven't this too.

Huh?

  my $cgi = new CGI;

And hey presto, $cgi has all the methods of the CGI class.

And so on and so forth for all other OO Perl. (And most other languages 
with OO capabilities, for that matter, including C++.)

What are you talking about? The fact that strings, scalars, etc aren't 
usually thought of as objects (even though they have both data and 
standard methods for operating on them)? 

Unlike what I suspect Randal would say, I like Python. I have no problem 
with it. It's a nice language. But that doesn't invalidate the fact that 
Perl does indeed have a complete and fully functional OO framework, even 
though the language didn't grow up around this framework the way Python 
did.
 


-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: How to accumulate Hashes of Array value with the same key?

2004-10-01 Thread Jan Eden
Edward Wijaya wrote on 01.10.2004:

On Thu, 30 Sep 2004 14:23:47 -0300, Shaw, Matthew [EMAIL PROTECTED]
wrote:

Thanks Matt,


  my %HoA = (key1 = ['A',1]);
  my %HoA2 = (key1 = ['B',2]);
  my %HoA3 = (key1 = ['C',2]);
 
  into:
 

Only this one works

 push @{$HoA{key1}}, ( @{$HoA2{key1}}, @{$HoA2{key1}});


Not this
 Sorry this should read:
 @{$HoA{key1}}, ( @{$HoA2{key1}}, @{$HoA3{key1}});

However what it gives is that it create one single array,
and not preserving the array that group ['A',1] etc, like before
namely:

print Dumper \%HoA;
$VAR1 = {
'key1' = [
'A',
1,
'B',
2,
'C',
2
  ]
  };

not;

$VAR1 = { 'key1' = ['A',1],['B',2],['C',2]};

So you want a hash of an array of arrays, right? This is adding another level of 
encapsulation.

So you could do this

#get the actual length of your target array and add one
$array_element = $#HoA{key1}++;
#push the new list of values into a new array inside the HoA
push $HoA{key1}-[$array_element], @{$HoA2{key1}}

Or did I get you wrong?

- Jan
-- 
There's no place like ~/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Randal L. Schwartz
 Nicolay == Nicolay A Vasiliev [EMAIL PROTECTED] writes:

Nicolay Let me be unagreed. Functionally complete OO language at least means
Nicolay the next thing: when I create some object (ie, declare some variable,
Nicolay maybe string), this already have necessary methods like Python or
Nicolay Ruby. Even C++ haven't such functionality. Of course Perl haven't this
Nicolay too.

I'm not quite following you, but I'm not sure why you think that
Python or Ruby writes your code for you.  There's as much (or little)
work to create an object in Perl as there is in either of those other
languages, in terms of what matters every day.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: How to accumulate Hashes of Array value with the same key?

2004-10-01 Thread Jan Eden
Edward Wijaya wrote on 01.10.2004:

On Thu, 30 Sep 2004 14:23:47 -0300, Shaw, Matthew [EMAIL PROTECTED]
wrote:

Thanks Matt,


  my %HoA = (key1 = ['A',1]);
  my %HoA2 = (key1 = ['B',2]);
  my %HoA3 = (key1 = ['C',2]);
 
  into:
 

Only this one works

 push @{$HoA{key1}}, ( @{$HoA2{key1}}, @{$HoA2{key1}});

It is valid Perl code, but it should not have the desired effect. Note the double 
reference to HoA2, corrected below.

Not this
 Sorry this should read:
 @{$HoA{key1}}, ( @{$HoA2{key1}}, @{$HoA3{key1}});

- Jan
-- 
There are 10 kinds of people:  those who understand binary, and those who don't

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Becoming Disenheartened - Everyone talks about Python and saysPerl is old news.

2004-10-01 Thread Gavin Henry
Randal L. Schwartz said:
 Gavin == Gavin Henry [EMAIL PROTECTED] writes:

 Gavin I have just read this famous peice:

 Gavin
 http://www.linuxjournal.com/article.php?sid=3882mode=order=thold=

 I'm pretty sure that Eric Raymond is not fully aware of
 test-first-development and Test::More and proper module packaging of
 Perl.  Otherwise, he wouldn't keep spouting his Perl sucks for big
 projects mantra.

Good to hear the other side of the coin.


 Perl's object model is complete.  Perl scales well to large projects.
 That Eric Raymond was unable to get it to scale is more telling about
 Eric than about Perl.

:-)

 I say this even though I consider Eric at least a strong acquaintence,
 having met him on quite a few occasions.  Eric is doing a disservice
 to the Perl community though, and on that, I cannot let stand.

Of course.

 --
 Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
 0095
 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
 See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl
 training!

 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Nicolay A. Vasiliev
To Randal and Chris. You all don't understand me. CGI is a module, 
earlier wrote and stored in a separate files. I don't mean such objects.

Python and Ruby don't write the code for me. But look at this Python code:
s = I am Perl guru;
new_s = s.replace(Perl, Python);
Huh? Remark, no addition modules.
The similar way is in Ruby and other nice.
By the way, these languages have people friendly exceptions handling ;) with 
try-except in Python and begin-rescue in Ruby.
http://www.soft411.com - Excellent soft archive
http://www.spamliquidator.com - Kill spam
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: sum a column

2004-10-01 Thread rmck
This is a beginner’s mailing list. I’m sorry my script is not at your level, I'm 
learning. 
I think telling someone on a beginners mailing list that they don’t have a clue is 
inappropriate.  
It shows me you have no clue. 


-Original Message-
From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 01, 2004 2:53 AM
To: [EMAIL PROTECTED]
Subject: Re: sum a column

Rmck wrote:
 Are you serious.

Indeed.

 Im not sure how to sum up the column... I tried by using the field
 and * it by the increment.

That awkward attempt seems to be made by someone who hasn't a clue
about programming.

 I have written every part of my script,

The script author does have a clue about programming.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response

-Original Message-
From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 01, 2004 2:53 AM
To: [EMAIL PROTECTED]
Subject: Re: sum a column

Rmck wrote:
 Are you serious.

Indeed.

 Im not sure how to sum up the column... I tried by using the field
 and * it by the increment.

That awkward attempt seems to be made by someone who hasn't a clue
about programming.

 I have written every part of my script,

The script author does have a clue about programming.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




substitution and assignment fun ( was RE: Becoming Disenheartened )

2004-10-01 Thread West, William M



Python and Ruby don't write the code for me. But look at this Python
code:

s = I am Perl guru;
new_s = s.replace(Perl, Python);


i always had trouble doing this in perl- just worked around it- then
realized that this shouldn't be hard when reading your post... so i
played...

$s = I am Perl guru;

$new_s = ($s =~ s/erl/ython/);

print $s \t $new_s \n;  #oops!  PrintsI am a Python guru
1

#but

($new_s = $s) =~ s/erl/ython/;
print $s \t $new_s \n;  

#prints   I am a Perl guru  I am a Python guru


Perl can be surprisingly intuitive-  using precedence rules to get this
done makes good sense to me :)




Huh? Remark, no addition modules.


*shrug*  eh- go figure



willy
http://www.hackswell.com/corenth

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Jenda Krynicky
From: Nicolay A. Vasiliev [EMAIL PROTECTED]
 Dear mr. Schwartz!
 Let me be unagreed. Functionally complete OO language at least means
 the next thing: when I create some object (ie, declare some variable,
 maybe string), this already have necessary methods like Python or
 Ruby. Even C++ haven't such functionality. Of course Perl haven't this
 too.

Sorry? Oh you want substr() to be a method, not a function, you want 
to write
$line.chomp();
instead of
chomp($line);
right?

I'd rather not.
Not everything has to be an object. Not everything has to be called 
like methods.

Would you like to have to write
$x = $y.sin().plus($y)
instead of
$x = sin($x) + $y;
?

There is a big difference between a functionaly complete OO language 
and a language that forces everything to be an object.

 I love Perl, it's great for concrete tasks class. But Python is good
 and clever too, don't you blacken this please even in a comedy form ;)

I did not see the word Python in Randal's message.

Jenda
= [EMAIL PROTECTED] === 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Chris Devers
On Fri, 1 Oct 2004, Nicolay A. Vasiliev wrote:

 To Randal and Chris. You all don't understand me.

There is a misunderstanding, but I'm not sure that it's Randal  me.

 CGI is a module, earlier
 wrote and stored in a separate files. I don't mean such objects.

And Python objects live where -- the sky? The stars? 

 Python and Ruby don't write the code for me. But look at this Python code:
 
 s = I am Perl guru;
 new_s = s.replace(Perl, Python);

No, you're using Python's built in string operators. Perl has them too:

 $s = I am a Perl guru;
 ( $new_s = $s ) =~ s/perl/python/;

Remark, no additional modules.

 
 Huh? Remark, no addition modules.

You're using methods defined by modules that live with Python.

Why bother splitting this hair? It's a distinction without a difference.
 
 By the way, these languages have people friendly exceptions handling ;) with
 try-except in Python and begin-rescue in Ruby.
 
You haven't come across eval{...} yet, have ya?  

The differences among Perl, Python, and Ruby are mostly semantic -- each 
of them can accomplish all the same tasks, but they wrap up the way to 
implement these tasks in ever-so-slightly different syntax. But so what? 
Any of them are *much* more pleasant to work with than Java, C/C++, or 
*shudder* Visual Basic. 


-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




newbie problem with Mail::POP3Client;

2004-10-01 Thread Jim Maas
I'm sure you've seen this one hundreds of times!
I copied the following script, downloaded and installed the POP3Client 
module but it doesn't want to connect to an external POP3 server for me, 
for some reason.  I have put in the correct pop3 server, username and 
password, at least the same ones that work for me and will connect Mozilla.

Any thoughts about how to find the problem and/or debug?
It runs, but I get You have -1 messages
I suspect the -1 means the variable has not been initialized or for some 
reason it will not connect to the server.

TIA
Jim
#!/usr/bin/perl
use strict;
use Mail::POP3Client;
my($pop, $num_mesg, $i);
$pop = new Mail::POP3Client( USER = username,
   PASSWORD = password,
   HOST = www.host.name );
$num_mesg = $pop-Count; #How many messages are there?
print (You have .$num_mesg. new messages.\n);
for ($i = 1; $i = $num_mesg; $i++) {
print $pop-Head($i), \n;#print header for each message
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Help needed: urgent

2004-10-01 Thread Wiggins d Anconia
Always group reply so that others can help and be helped and to avoid
getting (accidentally) ignored.


---
 But I need the output as an array like @db_results
 which would be sent 
 to a HTML template.
 The @db_results would look like
 
 db_results[0] = A  90  89  0   0
 db_results[1] = B  70  71  71  0
 db_results[2] = C   0  73  97  0
 

In this case you need to make an attempt. I have shown you an easy way
to build a structure that will make manipulating the data simple. You
need to put the effort into taking it the next step, if you fail, show
us what you tried and what the errors are, we are not here to write it
for you.

perldoc -f push
perldoc -f sprintf

Should give you a hint.

http://danconia.org

-
 
 Regards
 Rohit Satabhai
 
 
  --- Wiggins d Anconia [EMAIL PROTECTED] wrote: 
  
 
 ==
   Using DBI Perl Programming I get a database o/p as
   below
   Student SubjectCodeMarks
   
   A   190
   A   289
   B   170
   B   271
   B   371
   C   273
   C   397
   -
   Subject code may vary to any value.
   I need a report o/p in the following format and
   displayed in HTML
   Student 1   2  3  4   
   
   A  90  89 
   B  70  71  71
   C  73  97
   -
  
 
 
  
  I am not sure why you chose an array as your top
  level structure.
  Assuming each student is unique, and each subject is
  unique, you can use
  a hash of students, with the values of that being a
  hash of subjects,
  with the value being the mark. This eliminates the
  need for all the
  index munging.  For me it would look something like:
  
  use strict;
  use warnings;
  
  my $sth = [
  
  { 'student' = 'A', 'subject' = '1', 'mark' ='90'
  },
  { 'student' = 'A', 'subject' = '2', 'mark' ='89'
  },
  { 'student' = 'B', 'subject' = '1', 'mark' ='70'
  },
  { 'student' = 'B', 'subject' = '2', 'mark' ='71'
  },
  { 'student' = 'B', 'subject' = '3', 'mark' ='71'
  },
  { 'student' = 'C', 'subject' = '2', 'mark' ='73'
  },
  { 'student' = 'C', 'subject' = '3', 'mark' ='97'
  },
  
  ];
  
  my $students;
  foreach my $row (@$sth) {
  #while (my $row = $sth-fetchrow_hashref) {
 
  $students-{$row-{'student'}}-{$row-{'subject'}}
  = $row-{'mark'};
  }
  
  foreach my $student (sort keys %$students) {
  print $student, \t;
  foreach my $subject (sort keys
  %{$students-{$student}}) {
  print \t,
  $students-{$student}-{$subject};
  }
  print \n;
  }
  
  I have simulated your select above with the data you
  provided, switch
  the Cforeach to the commented Cwhile to have it
  use the actual
  statement handle.
  
  You can use Cprintf or formats to get the columns
  to line up right.
  
  snip code
  
  
 
 =
   Is there any other way in which this could be
  coded
   efficiently.
   Regards
   Rohit
  
  There is always another way. Better is always
  debatable
  
  Some Lite reading:
  
  perldoc perllol
  perldoc perldsc
  perldoc perlreftut
  perldoc perlref
  
  http://danconia.org
  
  -- 
  To unsubscribe, e-mail:
  [EMAIL PROTECTED]
  For additional commands, e-mail:
  [EMAIL PROTECTED]
  http://learn.perl.org/
  http://learn.perl.org/first-response
  
  
   
 
 
 Yahoo! India Matrimony: Find your partner online.
http://yahoo.shaadi.com/india-matrimony/
 
 
 X-UIDL: Q`!!QdS!aj8!D3'#!
 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Problem with subroutines with hash and var as input

2004-10-01 Thread Edward Wijaya
Dear Sirs,
I have the following code, that
take Hash of Hash as an iput.
Then I have function (see below) that takes
a hash and a variable as input.
This function will count the elements
of secondary hashes and delete the hash,
if it is below certain variable limit.
So with this :
my %new_hoh = reduce_hash(%hoh,3);
it should return
my %hoh = (
key2 =  {A = 'foo',
  B = 'bar',
  C = 'qux'}, );
But my subroutine doesn't work as it should.
Is there anything wrong with it?
Yours again,
Edward WIJAYA
SINGAPORE
__BEGIN__
use strict;
use warnings;
use Data::Dumper;
my %hoh = (
key1 =   {   A = 'foo',
  B = 'bar',},
key2 =  {A = 'foo',
  B = 'bar',
  C = 'qux'},
  key3 =  {A = 'foo',}
   );
my %new_hoh = reduce_hash(%hoh,3);
print Dumper \%new_hoh;
#---Subroutine that do the job---
sub reduce_hash {
my (%HoH,$limit) = @_;
foreach my $k ( keys %HoH ) {
my $count = 0;
for my $k2 ( keys %{ $HoH{$k} } ) {
$count++;
  }
  if ($count  $limit){
  delete $HoH{$k};
}
}
   return %HoH;
}
__END__
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: newbie problem with Mail::POP3Client;

2004-10-01 Thread Wiggins d Anconia
 I'm sure you've seen this one hundreds of times!


Uh, nope.  Which is really nice.
 
 I copied the following script, downloaded and installed the POP3Client 
 module but it doesn't want to connect to an external POP3 server for me, 
 for some reason.  I have put in the correct pop3 server, username and 
 password, at least the same ones that work for me and will connect
Mozilla.
 
 Any thoughts about how to find the problem and/or debug?
 

Did you turn on the DEBUG switch?  There is a section in the docs that
state that it will give an indication of errors. I copied your script,
turned it on, saw that the connection was successful by login was not. I
then attempted switching the AUTH_MODE for my connection to PASS (yes I
know what this means, do you? If not, learn before doing so.) and
everything then worked.

 It runs, but I get You have -1 messages
 

The docs state that currently the only way to check for successful
connection is to ask for the number of messages, with -1 indicating
connection failure. I suspect 0 is success but empty, and 1 meaning
success and with messages.

Granted this is fairly annoying and I would think getting that switched
is high on their list.

 I suspect the -1 means the variable has not been initialized or for some 
 reason it will not connect to the server.
 

-1 is initialization of the variable, just not a connection.

 TIA
 
 Jim
 

snip code

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: newbie problem with Mail::POP3Client;

2004-10-01 Thread Jim Maas
Thanks for this.  I'm not completely new but haven't found any sort of 
comprehensive docs, only cryptic ones.  Where might I find it?

By debug switch do you mean the optional debug_flag ?  No I haven't but 
about to.

No idea what AUTH_MODE means, and my two oreilly perl books don't tell 
me either but I'll try and Google for it.

Thanks, have moved on a little!
Jim
Did you turn on the DEBUG switch?  There is a section in the docs that
state that it will give an indication of errors. I copied your script,
turned it on, saw that the connection was successful by login was not. I
then attempted switching the AUTH_MODE for my connection to PASS (yes I
know what this means, do you? If not, learn before doing so.) and
everything then worked.
 

It runs, but I get You have -1 messages
   

The docs state that currently the only way to check for successful
connection is to ask for the number of messages, with -1 indicating
connection failure. I suspect 0 is success but empty, and 1 meaning
success and with messages.
Granted this is fairly annoying and I would think getting that switched
is high on their list.
 

I suspect the -1 means the variable has not been initialized or for some 
reason it will not connect to the server.

   

-1 is initialization of the variable, just not a connection.
 

TIA
Jim
   

snip code
http://danconia.org
 

--
==
Jim Maas Ph.D.
29 Amber Close
Earley, Reading, UK
RG6 7ED
0118-935-3283
0771-985-8698
jamaas at btinternet dot com


Re: Problem with subroutines with hash and var as input

2004-10-01 Thread Wiggins d Anconia
 Dear Sirs,
 
 I have the following code, that
 take Hash of Hash as an iput.
 
 Then I have function (see below) that takes
 a hash and a variable as input.
 This function will count the elements
 of secondary hashes and delete the hash,
 if it is below certain variable limit.
 
 So with this :
 my %new_hoh = reduce_hash(%hoh,3);


The above call will not work, because Perl flattens your hash (along
with the 3) into a single argument list. You either need to set the
order of arguments, and collect the hash at the end, or pass by
reference. This is an FAQ, see,

 perldoc -q 'How can I pass'

For more.
 
 it should return
 
 my %hoh = (
  key2 =  {A = 'foo',
B = 'bar',
C = 'qux'}, );
 
 But my subroutine doesn't work as it should.
 Is there anything wrong with it?
 
 Yours again,
 Edward WIJAYA
 SINGAPORE
 
 __BEGIN__
 use strict;
 use warnings;
 use Data::Dumper;
 
 my %hoh = (
  key1 =   {   A = 'foo',
B = 'bar',},
 
  key2 =  {A = 'foo',
B = 'bar',
C = 'qux'},
 
key3 =  {A = 'foo',}
 );
 
 my %new_hoh = reduce_hash(%hoh,3);

Essentially the above becomes,

my %new_hoh = reduce_hash(\%hoh, 3);

 print Dumper \%new_hoh;
 
 #---Subroutine that do the job---
 sub reduce_hash {
  my (%HoH,$limit) = @_;

And the above will stick everything in @_ into the hash. Instead it becomes,

my ($HoH, $limit) = @_;

And then you must dereference $HoH as a hash reference.

  foreach my $k ( keys %HoH ) {
  my $count = 0;
  for my $k2 ( keys %{ $HoH{$k} } ) {
  $count++;
}
if ($count  $limit){
delete $HoH{$k};
   }
  }
 
 return %HoH;
 }
 
 __END__
 

http://danconia.org


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Problem with subroutines with hash and var as input

2004-10-01 Thread John W. Krahn
Edward Wijaya wrote:
Dear Sirs,
I have the following code, that
take Hash of Hash as an iput.
Then I have function (see below) that takes
a hash and a variable as input.
This function will count the elements
of secondary hashes and delete the hash,
if it is below certain variable limit.
So with this :
my %new_hoh = reduce_hash(%hoh,3);
it should return
my %hoh = (
key2 =  {A = 'foo',
  B = 'bar',
  C = 'qux'}, );
But my subroutine doesn't work as it should.
Is there anything wrong with it?
Did you not see the warning message Odd number of elements in hash 
assignment?  Because your code should produce that warning.


__BEGIN__
use strict;
use warnings;
use Data::Dumper;
my %hoh = (
key1 =   {   A = 'foo',
  B = 'bar',},
key2 =  {A = 'foo',
  B = 'bar',
  C = 'qux'},
  key3 =  {A = 'foo',}
   );
my %new_hoh = reduce_hash(%hoh,3);
print Dumper \%new_hoh;
#---Subroutine that do the job---
sub reduce_hash {
my (%HoH,$limit) = @_;
You are assigning everything in @_ to %HoH and nothing to $limit.  Either put 
the scalar first in the list or pass a reference to the original hash.


foreach my $k ( keys %HoH ) {
my $count = 0;
for my $k2 ( keys %{ $HoH{$k} } ) {
$count++;
  }
  if ($count  $limit){
  delete $HoH{$k};
}
No need for $count or the second for loop:
  delete $HoH{ $k } if keys %{ $HoH{ $k } }  $limit;

}
   return %HoH;
}
__END__

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: newbie problem with Mail::POP3Client;

2004-10-01 Thread Wiggins d Anconia
Please bottom post

 
 Thanks for this.  I'm not completely new but haven't found any sort of 
 comprehensive docs, only cryptic ones.  Where might I find it?
 

Documentation for modules available on CPAN are always available online
in a quite readable format, for example,

http://search.cpan.org/~sdowd/Mail-POP3Client-2.16/POP3Client.pm

Also you can access most modules documentation after installation by
issuing,

perldoc module name
perldoc Mail::POP3Client

 By debug switch do you mean the optional debug_flag ?  No I haven't but 
 about to.

Well yes, but it is 'DEBUG', and is passed to the constructor.

 
 No idea what AUTH_MODE means, and my two oreilly perl books don't tell 
 me either but I'll try and Google for it.
 

AUTH_MODE sets the mode that the POP client will use to send the
password. The POP3 server on the other end may or may not support
encrypted (actually hashed but that's another topic) passwords in
which case the AUTH_MODE may need to be set to tell the client to send
the password in clear text.  Setting AUTH_MODE to BEST seems to allow
the most flexibility. 

 Thanks, have moved on a little!
 
 Jim
 

No problem.

http://danconia.org

 Did you turn on the DEBUG switch?  There is a section in the docs that
 state that it will give an indication of errors. I copied your script,
 turned it on, saw that the connection was successful by login was not. I
 then attempted switching the AUTH_MODE for my connection to PASS (yes I
 know what this means, do you? If not, learn before doing so.) and
 everything then worked.
 
   
 
 It runs, but I get You have -1 messages
 
 
 
 
 The docs state that currently the only way to check for successful
 connection is to ask for the number of messages, with -1 indicating
 connection failure. I suspect 0 is success but empty, and 1 meaning
 success and with messages.
 
 Granted this is fairly annoying and I would think getting that switched
 is high on their list.
 
   
 
 I suspect the -1 means the variable has not been initialized or for
some 
 reason it will not connect to the server.
 
 
 
 
 -1 is initialization of the variable, just not a connection.
 
   
 
 TIA
 
 Jim
 
 
 
 
 snip code
 
 http://danconia.org
 
   
 
 
 -- 
 
 
 ==
 Jim Maas Ph.D.
 29 Amber Close
 Earley, Reading, UK
 RG6 7ED
 
 0118-935-3283
 0771-985-8698
 jamaas at btinternet dot com
 
 
 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: How to accumulate Hashes of Array value with the same key?

2004-10-01 Thread Dave Gray
 $VAR1 = { 'key1' = ['A',1],['B',2],['C',2]};

That isn't going to do what you think it is... What you're asking for
there is to use the ['B', 2] array reference as a hash key...

$VAR1 = {
  'ARRAY(0x804ca54)' = ['C',2],
  'key1' = ['A',1]
};

In order to get close to what I think you're trying to describe, you'd
have to have another array reference and stuff those three arrays in
there.

$HoA = ( key1 = [
  ['A',1], ['B',2], ['C',3]
]);

Which is clunky when you want to detect duplicates, which is why I
suggested the hash.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: How to accumulate Hashes of Array value with the same key?

2004-10-01 Thread Dave Gray
On Fri, 1 Oct 2004 10:51:50 -0400, Dave Gray [EMAIL PROTECTED] wrote:
  $VAR1 = { 'key1' = ['A',1],['B',2],['C',2]};
 
 That isn't going to do what you think it is... What you're asking for
 there is to use the ['B', 2] array reference as a hash key...
 
 $VAR1 = {
   'ARRAY(0x804ca54)' = ['C',2],
   'key1' = ['A',1]
 };

Actually, the string representation of the ['B',2] is what gets used,
so the actual ['B',2] array gets thrown away.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: How to accumulate Hashes of Array value with the same key?

2004-10-01 Thread Edward Wijaya
On Fri, 1 Oct 2004 10:51:50 -0400, Dave Gray [EMAIL PROTECTED] wrote:
$HoA = ( key1 = [
  ['A',1], ['B',2], ['C',3]
]);
Which is clunky when you want to detect duplicates, which is why I
suggested the hash.

I think you are right Dave.
I will follow your suggestion.
Regards,
Edward WIJAYA
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Paul Cox
On Fri, 1 Oct 2004 09:21:45 -0400 (EDT), Chris Devers [EMAIL PROTECTED] wrote:
 On Fri, 1 Oct 2004, Nicolay A. Vasiliev wrote:
 
  To Randal and Chris. You all don't understand me.
 
 There is a misunderstanding, but I'm not sure that it's Randal  me.
 
  CGI is a module, earlier
  wrote and stored in a separate files. I don't mean such objects.
 
 And Python objects live where -- the sky? The stars?
 
  Python and Ruby don't write the code for me. But look at this Python code:
 
  s = I am Perl guru;
  new_s = s.replace(Perl, Python);
 
 No, you're using Python's built in string operators. Perl has them too:
 
  $s = I am a Perl guru;
  ( $new_s = $s ) =~ s/perl/python/;
 
 Remark, no additional modules.
 
 
  Huh? Remark, no addition modules.
 
 You're using methods defined by modules that live with Python.
 
 Why bother splitting this hair? It's a distinction without a difference.
 
  By the way, these languages have people friendly exceptions handling ;) with
  try-except in Python and begin-rescue in Ruby.
  
 You haven't come across eval{...} yet, have ya?
 
 The differences among Perl, Python, and Ruby are mostly semantic -- each
 of them can accomplish all the same tasks, but they wrap up the way to
 implement these tasks in ever-so-slightly different syntax. But so what?
 Any of them are *much* more pleasant to work with than Java, C/C++, or
 *shudder* Visual Basic.
 
 --
 Chris Devers
 
 
 
 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response
 
 

Just as a building contractor shows up to the job site with a tool box
full of conventional and power tools, the customer will only ask
questions regarding his capability, when he shows up with only a
screwdriver.


Paul Cox, President
Genesys Software Corporation
[EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: newbie problem with Mail::POP3Client;

2004-10-01 Thread Jim Maas
Hi Wiggins,
It works!  Thanks a bunch.  I'm no computer newbie but am new to Perl, 
and where does one get started?  It was the AUTH_MODE, which had to be 
set to 'PASS'.  The machine it is connecting to is a Sun running Linux, 
but I don't know the flavour or what mailer.  This is just a 
demo/prototype but will try to upgrade this security in future.

I know the module installed the MAIL::POP3Client documentation when it 
installed but my bash just says
no such command as perldoc ...

Another challenge!
Thanks
Jim
Wiggins d Anconia wrote:
Please bottom post
 

Thanks for this.  I'm not completely new but haven't found any sort of 
comprehensive docs, only cryptic ones.  Where might I find it?

   

Documentation for modules available on CPAN are always available online
in a quite readable format, for example,
http://search.cpan.org/~sdowd/Mail-POP3Client-2.16/POP3Client.pm
Also you can access most modules documentation after installation by
issuing,
perldoc module name
perldoc Mail::POP3Client
 

By debug switch do you mean the optional debug_flag ?  No I haven't but 
about to.
   

Well yes, but it is 'DEBUG', and is passed to the constructor.
 

No idea what AUTH_MODE means, and my two oreilly perl books don't tell 
me either but I'll try and Google for it.

   

AUTH_MODE sets the mode that the POP client will use to send the
password. The POP3 server on the other end may or may not support
encrypted (actually hashed but that's another topic) passwords in
which case the AUTH_MODE may need to be set to tell the client to send
the password in clear text.  Setting AUTH_MODE to BEST seems to allow
the most flexibility. 

 

Thanks, have moved on a little!
Jim
   

No problem.
http://danconia.org
 

Did you turn on the DEBUG switch?  There is a section in the docs that
state that it will give an indication of errors. I copied your script,
turned it on, saw that the connection was successful by login was not. I
then attempted switching the AUTH_MODE for my connection to PASS (yes I
know what this means, do you? If not, learn before doing so.) and
everything then worked.

 

It runs, but I get You have -1 messages
  

   

The docs state that currently the only way to check for successful
connection is to ask for the number of messages, with -1 indicating
connection failure. I suspect 0 is success but empty, and 1 meaning
success and with messages.
Granted this is fairly annoying and I would think getting that switched
is high on their list.

 

I suspect the -1 means the variable has not been initialized or for
   

some 
 

reason it will not connect to the server.
  

   

-1 is initialization of the variable, just not a connection.

 

TIA
Jim
  

   

snip code
http://danconia.org

 

--
==
Jim Maas Ph.D.
29 Amber Close
Earley, Reading, UK
RG6 7ED
0118-935-3283
0771-985-8698
jamaas at btinternet dot com

   


 

--
==
Jim Maas Ph.D.
29 Amber Close
Earley, Reading, UK
RG6 7ED
0118-935-3283
0771-985-8698
jamaas at btinternet dot com


Re: substitution and assignment fun ( was RE: Becoming Disenheartened )

2004-10-01 Thread Nicolay A. Vasiliev
No doubt please, I know about regular expressions and Python/Ruby 
support them fully. I only showed the approach of method calling. There 
could be not replace method.

William M West wrote:

Python and Ruby don't write the code for me. But look at this Python
code:
s = I am Perl guru;
new_s = s.replace(Perl, Python);

i always had trouble doing this in perl- just worked around it- then
realized that this shouldn't be hard when reading your post... so i
played...
$s = I am Perl guru;
$new_s = ($s =~ s/erl/ython/);
print $s \t $new_s \n;  #oops!  Prints  I am a Python guru
1
#but
($new_s = $s) =~ s/erl/ython/;
print $s \t $new_s \n;  

#prints   I am a Perl guru  I am a Python guru
Perl can be surprisingly intuitive-  using precedence rules to get this
done makes good sense to me :)


Huh? Remark, no addition modules.

*shrug*  eh- go figure

willy
http://www.hackswell.com/corenth
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Problem with subroutines with hash and var as input

2004-10-01 Thread Edward Wijaya
On Fri, 01 Oct 2004 07:41:43 -0700, John W. Krahn [EMAIL PROTECTED] wrote:
Thanks,
No need for $count or the second for loop:
John, your one-liner certainly makes my sub
looks better.
Either put the scalar first in the list or pass a reference to the  
original hash.
Now, I also tried with pass by reference
  my ($HoH,$limit) = @_;
foreach my $k ( keys %$HoH ) {   # This two  
don't work
 delete $HoH{ $k } if keys %${ $HoH{ $k } }  $limit;# What's  
wrong with my deref?
}
   return %HoH;

What's wrong with my deref?
Regards
Edward WIJAYA
SINGAPORE
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: substitution and assignment fun ( was RE: Becoming Disenheartened )

2004-10-01 Thread Chris Devers
On Fri, 1 Oct 2004, Nicolay A. Vasiliev wrote:

 No doubt please, I know about regular expressions and Python/Ruby 
 support them fully. I only showed the approach of method calling. 
 There could be not replace method.

You're arguing about semantics, but you concede that the functionality 
you're describing exists just as succinctly in both languages. 

So, again -- so what ? It's a difference without a distinction. 

Python  Ruby implement these operations with a .method() syntax.

Perl generally implements them with a function() syntax.

The two sides are far more similar than different. Who cares?



-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread NYIMI Jose \(BMB\)


 -Original Message-
 From: Nicolay A. Vasiliev [mailto:[EMAIL PROTECTED] 
 Sent: Friday, October 01, 2004 2:45 PM
 To: [EMAIL PROTECTED]
 Subject: Re: Becoming Disenheartened - Everyone talks about 
 Python and says Perl is old news.
 
 
 To Randal and Chris. You all don't understand me. CGI is a module, 
 earlier wrote and stored in a separate files. I don't mean 
 such objects.
 
 Python and Ruby don't write the code for me. But look at this 
 Python code:
 
 s = I am Perl guru;
 new_s = s.replace(Perl, Python);
 

With this willing to treat everything as object you end up with
Ugly code such as the following:
http://www.python.org/cgi-bin/moinmoin/CgiScripts

#!/usr/bin/env python

import cgi

print Content-type: text/html
print
print

print 
html

headtitleSample CGI Script/title/head

body

  h3 Sample CGI Script /h3


form = cgi.FieldStorage()
if form.has_key( message ):
message = form[message].value
else:
message = (no message)

print 

  pPrevious message: %s/p

  pform:/p

  form method=post action=index.cgi
pmessage: input type=text name=message//p
  /form

/body

/html
 % message


That I let the beginners-list to show you how it can be nicer written in Perl :)

José.


 DISCLAIMER 

This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer.

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Passing options to command in a system call

2004-10-01 Thread Jan Eden
Hi,

I try to call wget using system like this:

system(wget -O /dev/null, http://janeden.org/test/file.txt;);

This does not work:

Can't exec wget -O /dev/null: No such file or directory at ./wgetrec.pl line 6.

Ok, so how about this:

system(wget, -O /dev/null http://janeden.org/test/file.txt;);

No go:

wget: missing URL

Without additional options,

system(wget, http://janeden.org/test/file.txt;);

works fine.

How can I pass an option to system's first argument in a setting like this?

(I know I can use a module instead of calling wget, but this is a more general issue.)

Thanks,

Jan
-- 
If all else fails read the instructions. - Donald Knuth

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Doug Lewis
I won't even reply to the person that said, perl is old news.  And that everyone talks 
about Python.  That is just stupid.  Most people either talk about C, C++, or Java.  
Then comes perl.
 
Perl is still way more talked about than Python In my Experience.
 
Perl makes things much simpler.


NYIMI Jose (BMB) [EMAIL PROTECTED] wrote:


 -Original Message-
 From: Nicolay A. Vasiliev [mailto:[EMAIL PROTECTED] 
 Sent: Friday, October 01, 2004 2:45 PM
 To: [EMAIL PROTECTED]
 Subject: Re: Becoming Disenheartened - Everyone talks about 
 Python and says Perl is old news.
 
 
 To Randal and Chris. You all don't understand me. CGI is a module, 
 earlier wrote and stored in a separate files. I don't mean 
 such objects.
 
 Python and Ruby don't write the code for me. But look at this 
 Python code:
 
 s = I am Perl guru;
 new_s = s.replace(Perl, Python);
 

With this willing to treat everything as object you end up with
Ugly code such as the following:
http://www.python.org/cgi-bin/moinmoin/CgiScripts

#!/usr/bin/env python

import cgi

print Content-type: text/html
print
print

print 






Sample CGI Script 


form = cgi.FieldStorage()
if form.has_key( message ):
message = form[message].value
else:
message = (no message)

print 


Previous message: %s



form:




message:  [input] 






 % message


That I let the beginners-list to show you how it can be nicer written in Perl :)

José.


 DISCLAIMER 

This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer.

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!

Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread UV
On Fri, 2004-10-01 at 11:04 +0200, Gabor Urban wrote:
 Hi guys,
 
 this thread seems to expand into something unworthy of this mailing
 list. You can not compare a cup of tea with a horse, these are two
 totally different things.
Don't be ridiculous, of course they don't compare, a horse is _way_ more
useful than a cup of tea, horses plow fields, they provide
transportation, and when attached to a Hansom Cab, they can even get men
laid!
A cup of tea has none of these features.  So please, no more disparaging
horses by comparing them to cups of tea, this sort of madness _must_
stop!

--uv



signature.asc
Description: This is a digitally signed message part


RE: Passing options to command in a system call

2004-10-01 Thread Bob Showalter
Jan Eden wrote:
 Hi,
 
 I try to call wget using system like this:
 
 system(wget -O /dev/null, http://janeden.org/test/file.txt;);
 
 This does not work:
 
 Can't exec wget -O /dev/null: No such file or directory at
 ./wgetrec.pl line 6. 
 
 Ok, so how about this:
 
 system(wget, -O /dev/null http://janeden.org/test/file.txt;);
 
 No go:
 
 wget: missing URL
 
 Without additional options,
 
 system(wget, http://janeden.org/test/file.txt;);
 
 works fine.
 
 How can I pass an option to system's first argument in a setting like
 this? 

This is explained in 'perldoc -f system'

You either need to separate all the args yourself, or pass a single string
to system so the shell can split the args. You're trying to do both.

either:

   system(wget -O /dev/null http://janeden.org/test/file.txt;)

or:

   system('wget', '-O', '/dev/null', 'http://janeden.org/test/file.txt')

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Passing options to command in a system call

2004-10-01 Thread Doug Lewis
I haven't used the wget program before, but try adding a comma after your -O.  I did 
that and I got it working.

Jan Eden [EMAIL PROTECTED] wrote:Hi,

I try to call wget using system like this:

system(wget -O /dev/null, http://janeden.org/test/file.txt;);

This does not work:

Can't exec wget -O /dev/null: No such file or directory at ./wgetrec.pl line 6.

Ok, so how about this:

system(wget, -O /dev/null http://janeden.org/test/file.txt;);

No go:

wget: missing URL

Without additional options,

system(wget, http://janeden.org/test/file.txt;);

works fine.

How can I pass an option to system's first argument in a setting like this?

(I know I can use a module instead of calling wget, but this is a more general issue.)

Thanks,

Jan
-- 
If all else fails read the instructions. - Donald Knuth

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Wiggins d Anconia
 
 On Fri, 2004-10-01 at 11:04 +0200, Gabor Urban wrote:
  Hi guys,
  
  this thread seems to expand into something unworthy of this mailing
  list. You can not compare a cup of tea with a horse, these are two
  totally different things.
 Don't be ridiculous, of course they don't compare, a horse is _way_ more
 useful than a cup of tea, horses plow fields, they provide
 transportation, and when attached to a Hansom Cab, they can even get men
 laid!
 A cup of tea has none of these features.  So please, no more disparaging
 horses by comparing them to cups of tea, this sort of madness _must_
 stop!
 
 --uv
 

Teach a man to fish, and he will sit in a boat and drink beer all day.

Careful some of the Briton's are probably pretty sensitive over their
tea ;-)

I think this thread has definitely deteriorated.

http://danconia.org


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Nicolay A. Vasiliev
Chris Devers wrote:
CGI is a module, earlier
wrote and stored in a separate files. I don't mean such objects.



And Python objects live where -- the sky? The stars?
  

To create $cgi = new CGI you should make declaration use CGI, 
shouldn't you? I meant only this

  

Python and Ruby don't write the code for me. But look at this Python 
code:

s = I am Perl guru;
new_s = s.replace(Perl, Python);



No, you're using Python's built in string operators. Perl has them too:
  


Python doc quotation:
2.3.6.1 String Methods
...
replace( old, new[, count])
Return a copy of the string with all occurrences of substring old 
replaced by new. If the optional argument count is given, only the first 
count occurrences are replaced.


 $s = I am a Perl guru;
 ( $new_s = $s ) =~ s/perl/python/;

Remark, no additional modules.
  

Agreed, but this is RE approach. This is supported by Python/Perl, but I 
meant another thing (hope you understand me).



You haven't come across eval{...} yet, have ya?  

The differences among Perl, Python, and Ruby are mostly semantic -- each
of them can accomplish all the same tasks, but they wrap up the way to
implement these tasks in ever-so-slightly different syntax. But so what?
  

Agreed. I am against the blacking of these languages expressed by Mr. 
Randal.

--
-
Nicolay A. Vasiliev
http://www.spamliquidator.com - Real spam fighter
http://www.soft411.com - Excellent soft archive
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Problem with subroutines with hash and var as input

2004-10-01 Thread John W. Krahn
Edward Wijaya wrote:
On Fri, 01 Oct 2004 07:41:43 -0700, John W. Krahn [EMAIL PROTECTED] wrote:
Either put the scalar first in the list or pass a reference to the  
original hash.
Now, I also tried with pass by reference
  my ($HoH,$limit) = @_;
foreach my $k ( keys %$HoH ) {   # This two  
don't work
 delete $HoH{ $k } if keys %${ $HoH{ $k } }  $limit;# What's  
wrong with my deref?
Since $HoH now contains a reference to a hash you have to dereference it properly.
delete $HoH-{ $k } if keys %${ $HoH-{ $k } }  $limit;

}
   return %HoH;
return %$HoH;
But you don't really have to return the hash now as you are using a reference 
to the original hash which means that the original hash is modified by your 
subroutine.

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Passing options to command in a system call

2004-10-01 Thread Errin Larsen
On Fri,  1 Oct 2004 17:41:50 +0200, Jan Eden [EMAIL PROTECTED] wrote:
 Hi,

  Hello!

SNIP

 
 How can I pass an option to system's first argument in a setting like this?
 
 (I know I can use a module instead of calling wget, but this is a more general 
 issue.)
 
 Thanks,
 
 Jan
 --

This is ironic:

 If all else fails read the instructions. - Donald Knuth

First, check out 'perldoc -f system'  The answer to you question is in
the first paragraph!

Second, try passing EACH argument as a seperate value:
  ((WARNING: I don't have wget, so I couldn't test this!))

system(wget, -O, /dev/null, http://janeden.org/test/file.txt;);

--Errin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Problem with subroutines with hash and var as input

2004-10-01 Thread Edward Wijaya
On Fri, 01 Oct 2004 08:58:44 -0700, John W. Krahn [EMAIL PROTECTED] wrote:
Since $HoH now contains a reference to a hash you have to dereference it  
properly.
 delete $HoH-{ $k } if keys %${ $HoH-{ $k } }  $limit;
 return %$HoH;

I apologize for insisting John.
Tried as you suggested:
64: sub reduce_hash2 {
65:my ($HoH,$limit) = @_;
66:foreach my $k ( keys %${HoH} ) {
67: delete $HoH-{ $k } if keys %${ $HoH-{ $k } }  $limit;
68:}
69:   return %$HoH;
70: }
with this command:
my %new_hoh = reduce_hash2(\%hoh,2);
Gives error:
Not a SCALAR reference at testcode.pl line 67.
Regards,
Edward WIJAYA
SINGAPORE
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread West, William M
With this willing to treat everything as object you end up with
Ugly code such as the following:
http://www.python.org/cgi-bin/moinmoin/CgiScripts

(code snipped to save space)


i found the Python script to be very readable- i am far more comfortable
with Perl syntax, but it worked for me.

I think there are two arguments which can be made here- both good.

1.  code syntax (limitation/flexibility/readability) - how languages
differ and language preference.

2.  Language strengths and weaknesses (outside of syntax).


My impression was that OO in Perl has historically been fraught with 
CPU overhead - this will change in Perl 6?  (argument number 2)

I like the functional() as apposed to the menthod.syntax() because i can
more easily visualise the path that data takes through the code.  makes
my life easier (argument number 1)


for me something like $new_s = change($s, $string); just works better
for me.  anyway, the advantages of encapsulation are easily produced in
functional() code with good coding practices.

of course, now we're talking about meta topics as apposed to particular
Perl
questions- but I think the argument is worth while.


willy
http://www.hackswell.com/corenth 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Randal L. Schwartz
 Nicolay == Nicolay A Vasiliev [EMAIL PROTECTED] writes:

Nicolay Python and Ruby don't write the code for me. But look at this Python code:

Nicolay s = I am Perl guru;
Nicolay new_s = s.replace(Perl, Python);

$s = I am a Perl guru;
($new_s = $s) =~ s/Perl/Python/;

No additional modules.

Nicolay By the way, these languages have people friendly exceptions handling ;) with 
try-except in Python and begin-rescue in Ruby.

Just like Perl, again.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Passing options to command in a system call

2004-10-01 Thread Jan Eden
Thanks, Errin, Doug and Bob,

Errin Larsen wrote on 01.10.2004:

On Fri,  1 Oct 2004 17:41:50 +0200, Jan Eden [EMAIL PROTECTED]
wrote:

How can I pass an option to system's first argument in a setting
like this?

This is ironic:

If all else fails read the instructions. - Donald Knuth

First, check out 'perldoc -f system'  The answer to you question is
in the first paragraph!

I *did* read the perldoc, of course. But I obviously misunderstood it and carefully 
avoided *both* working combination (single argument or four arguments to system). I 
thought that using three arguments (command, options, url) would cause Perl to execute

wget -O /dev/null http://janeden.org

Obviously, it only does this when getting the whole string split on whitespace *or* in 
one piece. Should have tried before wasting your time. Sorry.

- Jan
-- 
How many Microsoft engineers does it take to screw in a lightbulb? None. They just 
redefine dark as the new standard.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread JupiterHost.Net
 CGI is a module, earlier
 wrote and stored in a separate files. I don't mean such objects.
 
 
 And Python objects live where -- the sky? The stars?
   
To create $cgi = new CGI you should make declaration use CGI, 
shouldn't you? I meant only this
Err, you keep arguing about pointless things:
 #!/usr/local/bin/python
 import cgi
 cgi.test()
 ...
Does cgi.test() still work without the import cgi ?
So you have to do basically the equivalent of use CGI to be able to use 
the cgi object and therefore have access to all its functions.

And if you say, Well I don't have to do my $cgi = new CGI so its 
better is like me saying that perl is better because my shebang line 
takes up less file space that your python path. It's just pointless.

   
 Python and Ruby don't write the code for me. But look at this Python 
code:
 
 s = I am Perl guru;
 new_s = s.replace(Perl, Python);
 
 
 No, you're using Python's built in string operators. Perl has them too:
   

Python doc quotation:
2.3.6.1 String Methods
...
replace( old, new[, count])
Return a copy of the string with all occurrences of substring old 
replaced by new. If the optional argument count is given, only the first 
count occurrences are replaced.


  $s = I am a Perl guru;
  ( $new_s = $s ) =~ s/perl/python/;
 
 Remark, no additional modules.
   
Agreed, but this is RE approach. This is supported by Python/Perl, but I 
meant another thing (hope you understand me).
No I don't understand.
Who cares if you do a regex or a built in function/method that does the 
regex for you?

You're arguments are all like My dad can beat up your dad when the 
truth is, in different circumstances either dad could beat up either dad.

Its better to you because you understand it, which doesn't make it 
better or worse.

In my opinion and experience Perl does everything I've ever needed to do 
programming wise, its easy to learn and expand, and has been easier to 
do that with than any other language I've played with. Your experience 
may be different. So in that sense my dad can beat up your dad, but in 
your experience it would seem your dad can beat up my dad :)

So to the OP: chin up! Python (or any other language) isn't going to 
replace Perl (and Perl is not going to replace any other languages), 
especially with lame arguments for Python like we've seen here ;p

Nobody's mentioned Moto yet :) Its pretty cool
Just my .02 :)
Lee.M - JupiterHost.Net
(By the way we offer Python as one of our features to appeal to more 
customers, can't we all just get along ;p)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: sum a column

2004-10-01 Thread Gunnar Hjalmarsson
Rmck wrote:
Gunnar Hjalmarsson wrote:
Rmck wrote:
Im not sure how to sum up the column... I tried by using the
field and * it by the increment.
That awkward attempt seems to be made by someone who hasn't a
clue about programming.
I have written every part of my script,
The script author does have a clue about programming.
This is a beginner's mailing list. I'm sorry my script is not at
your level, I'm learning.
Please show us that you are learning! Prove that I'm wrong by showing
us how you applied Wiggins' helpful advice in your code.
I think telling someone on a beginners mailing list that they don't
have a clue is inappropriate.
But I didn't say that about the script author, and you claim to be the
script author, so what's the problem?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



cgi scripts

2004-10-01 Thread Adamiec, Larry
Hello,

I am trying to send form data via a UNIX CGI Perl script to a MS Access
database.  The form and the CGI script are both on a secure web server.
The unix script must be used to process the credit card information from
the form.  I intend to use the POST method of sending the form data to
the CGI script.  If the credit card is rejected for any reason, then the
UNIX CGI script will send an error message to the user's browser and
stop processing things.  If the credit card has been successfully
processed, I need to strip out the credit card info (using perl regular
expressions or something else) and pass the remainder of the data to a
MS ASP script on a Windows server which will insert the data in to the
database.

My question:  How do I get the form data to the MS window ASP script
using the POST method?  I have tried using the GET method successfully (
print Location: http://ip_address?ENV{'QUERY_STRING;'} ) but I don't
want any data in the URL.

Lawrence Adamiec
Unix Manager
Rm. 525B 
565 W. Adams St.
Chicago-Kent College of Law
Illinois Institute of Technology
Chicago, Illinois
312-906-5301


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: sum a column

2004-10-01 Thread West, William M

But I didn't say that about the script author, and you claim to be the
script author, so what's the problem?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


looks like a communications problem...  

The script author does have a clue about programming.

is easy to misread as saying does not if you pass your eyes over it 
quickly...i did that the first time i saw it... *shrug*  





willy
http://www.hackswell.com/corenth 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Nicolay A. Vasiliev
I didn't mean CGI, only standart types.
JupiterHost.Net wrote:
 CGI is a module, earlier
 wrote and stored in a separate files. I don't mean such objects.
 
 
 And Python objects live where -- the sky? The stars?
   
To create $cgi = new CGI you should make declaration use CGI, 
shouldn't you? I meant only this

Err, you keep arguing about pointless things:
 #!/usr/local/bin/python
 import cgi
 cgi.test()
 ...
Does cgi.test() still work without the import cgi ?
--
-
Nicolay A. Vasiliev
http://www.spamliquidator.com - Real spam fighter
http://www.soft411.com - Excellent soft archive
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: cgi scripts

2004-10-01 Thread Gunnar Hjalmarsson
Larry Adamiec wrote:
How do I get the form data to the MS window ASP script using the
POST method?  I have tried using the GET method successfully ( 
print Location: http://ip_address?ENV{'QUERY_STRING;'} ) but I
don't want any data in the URL.
Check out the libwww-perl package, e.g. LWP::UserAgent.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Check for valid email address

2004-10-01 Thread Gunnar Hjalmarsson
Randal L. Schwartz wrote:
Gunnar == Gunnar Hjalmarsson [EMAIL PROTECTED] writes:
Gunnar Or: This is a function I'm using in a couple of programs to check the
Gunnar syntax, and that I believe is sufficient in practice:
Gunnar  sub emailsyntax {
Gunnar  return 1 unless
Gunnarmy ($localpart, $domain) = shift =~ /^(.+)@(.+)/;
Gunnar  my $char = '[^()@,;:\/\s\'|.]';
Gunnar  return 1 unless $localpart =~ /^$char+(?:\.$char+)*$/ or
Gunnar$localpart =~ /^[^,]+$/;
Gunnar  $domain =~ /^$char+(?:\.$char+)+$/ ? 0 : 1;
Gunnar  }
No, that incorrectly invalidates
fred[EMAIL PROTECTED]
which is a valid working address
I never claimed the function to be perfect, and I said in practice. 
Noone is using such an address in real life unless they are asking for 
trouble; I'm sure you don't either.

Randal, you have that address only to demonstrate shortcomings in 
various attempts to check email syntaxes, right? ;-)

Just use Email::Valid.  It has the right idea.
I suggested that also, but the reason I don't use it in those two 
programs I mentioned is that the programs are publicly available for 
downloading, and I always think twice before making such programs 
dependent on non-standard modules.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread JupiterHost.Net

Nicolay A. Vasiliev wrote:
I didn't mean CGI, only standart types.
Everyone is just using your own examples as examples of why your 
arguments are moot :)

That's the last .02 I'm spending on this crazy thread :)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Check for valid email address

2004-10-01 Thread Randal L. Schwartz
 Gunnar == Gunnar Hjalmarsson [EMAIL PROTECTED] writes:

Gunnar I never claimed the function to be perfect, and I said in
Gunnar practice. Noone is using such an address in real life unless they are
Gunnar asking for trouble; I'm sure you don't either.

A frequent poster of past to comp.lang.perl.misc, whom I've met
a few times when I was hanging out at NY.pm, uses the Email
address of [EMAIL PROTECTED].

I'm planning on shifting all stonehenge email addresses to something
with  in them soon, to prevent them from being scraped wherever they
appear.

So yes, you better darn well support 822, or you'll upset a lot more
than my toy user.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-10-01 Thread Randal L. Schwartz
 William == William M West [EMAIL PROTECTED] writes:

William My impression was that OO in Perl has historically been fraught with 
William CPU overhead - this will change in Perl 6?  (argument number 2)

FUD FUD FUD.

*All* late binding takes a bit of time.  Perl caches what it can.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




How TO CREATE RUNTIME CONTROLS

2004-10-01 Thread atul ashpalia
Hi All,
I want to create runtime controls on the same webpage.
For example, 
my webpage will contain a textbox, a hyperlink  a
submit button. 
I want to achieve the following functionality :
That is, if i click on the hyperlink, a new textboxes
should be placed below the first one, if i click the
second time on the hyperlink, another new textbox will
be appended/placed below the 2nd one...and so on...
Then on submit button, a new page is called where the
data will be displaced which the user enters.

kindly help me,
thanks in advance,
atul.



___
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response