Re: IMAP email client: style & security

2010-05-11 Thread Eitan Adler
I made the changes below and I'd like to know if there is anything else I could do to improve the quality of my code. use constant false => 0; >>use constant true => 1; >> > > Constants are usually written in all uppercase to distinguish them from > keywords, functions, operators

Re: IMAP email client: style & security

2010-05-11 Thread Uri Guttman
> "EA" == Eitan Adler writes: >> Constants are usually written in all uppercase to distinguish them from >> keywords, functions, operators and subroutines. How did you choose the >> arbitrary values 0 and 1 for false and true instead of using other values? >> Why did you name them fa

fork, read from child process and timeout

2010-05-11 Thread Weizhong Dai
Hi all, - $pid = open(README, "program arguments |") or die "Couldn't fork: $!\n"; while () { # ... } close(README) -- my problem is: I read from README, but if waiting for next input is timeout, end reading. Is there any timer

Re: How to use the module: XML::Parser

2010-05-11 Thread Jeff Pang
2010/5/11 Parag Kalra : > Hey All, > > I am trying to design some scripts using the module - XML::Parser > > To start  learning I have a very basic scenario. Suppose I have following > XML file: > > > My Tag1 > My Tag2 > My Tag3 > > > I want to save the the tags as the keys of a Hash and respecti

Re: fork, read from child process and timeout

2010-05-11 Thread Jeff Pang
2010/5/11 Weizhong Dai : > Hi all, > > - > $pid = open(README, "program arguments |")  or die "Couldn't fork: $!\n"; > while () { >    # ... > } > close(README) > -- > > my problem is: I read from README, but if  waiting for next input

Re: IMAP email client: style & security

2010-05-11 Thread Eitan Adler
> perl style is to just use boolean tests and not check for equality to > some constants. and this means not using FALSE and TRUE constants. so > you should drop this habit as you won't see it much in perl. > Alright - changed. This is exactly why I sent this email to the list - to learn perl styl

AW: fork, read from child process and timeout

2010-05-11 Thread Thomas Bätzler
Weizhong Dai asked: > - > $pid = open(README, "program arguments |") or die "Couldn't fork: > $!\n"; > while () { > # ... > } > close(README) > -- > > my problem is: I read from README, but if waiting for next input is > timeou

Re: How to use the module: XML::Parser

2010-05-11 Thread Shlomi Fish
Hi Parag, On Tuesday 11 May 2010 08:50:21 Parag Kalra wrote: > Hey All, > > I am trying to design some scripts using the module - XML::Parser > > To start learning I have a very basic scenario. Suppose I have following > XML file: > > > My Tag1 > My Tag2 > My Tag3 > > > I want to save the t

UTF-8 and Internal Representation of (Latin1) Characters

2010-05-11 Thread Peter Daum
Because I had little need for it I had tried to just ignore Perl's Unicode support as long as possible. Now it looks like I can't do that anymore, so I started looking through the various docs. One thing that confused me: several sources mention Perl using 8-bit characters as long as possible, whi

sort hash with an array as the value

2010-05-11 Thread Owen
I have this statement; foreach my $key ( keys %filehash ) { print "$key $filehash{$key}->[0]\t\t\t$filehash{$key}->[3]\t $filehash{$key}->[2]\t $filehash{$key}->[1]\n"; } but wish to sort the output by $filehash{$key}->[0]. Is it possible? How do I do this? I can't make a separate hash of t

AW: sort hash with an array as the value

2010-05-11 Thread Thomas Bätzler
Owen asked: > I have this statement; > > foreach my $key ( keys %filehash ) { > print "$key $filehash{$key}->[0]\t\t\t$filehash{$key}->[3]\t > $filehash{$key}->[2]\t $filehash{$key}->[1]\n"; > } > > but wish to sort the output by $filehash{$key}->[0]. Is it possible? > How do I do this? for

Re: sort hash with an array as the value

2010-05-11 Thread Shlomi Fish
Hi Owen, On Tuesday 11 May 2010 14:10:49 Owen wrote: > I have this statement; > > foreach my $key ( keys %filehash ) { > print "$key $filehash{$key}->[0]\t\t\t$filehash{$key}->[3]\t > $filehash{$key}->[2]\t $filehash{$key}->[1]\n"; > } > > but wish to sort the output by $filehash{$key}->[0].

Re: Remove and substitute character in a string with a regex

2010-05-11 Thread C.DeRykus
On May 10, 3:53 am, shlo...@iglu.org.il (Shlomi Fish) wrote: > Hi Thomas, > > a few comments on your code. > > On Monday 10 May 2010 13:45:53 Thomas Bätzler wrote: > > > > > Finalfire asked: > > > Hello guys! I'm skilling regex using Perl and i've some trouble about > > > a simple try: > > > i've

Re: AW: AW: Remove and substitute character in a string with a regex

2010-05-11 Thread Dr.Ruud
Thomas Bätzler wrote: > (attribution fixed) Shlomi Fish: use warnings is preferable to the -w flag. Not in my book. The command line switch turns on warnings globally, whereas the "use warnings;" pragma only enables them in the current lexical scope. So by using the command line switch, I ge

Re: Remove and substitute character in a string with a regex

2010-05-11 Thread C.DeRykus
On May 9, 10:03 am, blog.h...@gmail.com (Finalfire) wrote: > Hello guys! I'm skilling regex using Perl and i've some trouble about > a simple try: > i've a string like: > > $string = "HELLAAABB"; > > and i want to manipulate in that way: HELL4O3ABB4C;You can simply > notice that when i have

Re: Closing File Handles

2010-05-11 Thread Whacky™
On Apr 30, 9:30 pm, jcas...@activenetwerx.com ("Joseph L. Casale") wrote: > Is it required to manually close a file handle I used > to write debugging info to when the Perl scripts exits? > > Seems like a waste of effort at the end of the script to > test `if debug...` and close the fh after? > > T

Developing Complex Event Processing (CEP) applications in perl

2010-05-11 Thread Amit Saxena
Hello all, Please let me know if anybody has any idea on the development of Complex Event Processing (CEP) applications in perl. I have been assigned a task for development of a complex event processing (CEP) application and I would like to do the same in perl that is my favorite language. Thank

Re: fork, parallel and global values

2010-05-11 Thread C.DeRykus
On May 10, 7:07 am, raphael.j...@gmail.com ("raphael()") wrote: > Hello, > > -- CODE -- > > #!/usr/bin/env perl > > use strict; > use warnings; > use Parallel::ForkManager; > > # Parallel::ForkManager > my $pfm = Parallel::ForkManager->new(5); > > my %hash; > for my $num ( qw/ 1 2 3

Re: Developing Complex Event Processing (CEP) applications in perl

2010-05-11 Thread Jeff Pang
2010/5/11 Amit Saxena : > Hello all, > > Please let me know if anybody has any idea on the development of Complex > Event Processing (CEP) applications in perl. > Maybe POE is your friend: http://poe.perl.org/ -- Tech support agency in China http://duxieweb.com/ -- To unsubscribe, e-mail: beg

Re: Still pondering working with hashs

2010-05-11 Thread Harry Putnam
Shawn H Corey writes: > Harry Putnam wrote: >> But, is there an easier way? > > Invert both hashes and find the keys in both inverses. Shawn, hoping to pester you once more about this topic. first: Hashes involved are built like this (Using File::Find nomenclature): (NOT CODE... Just descri

Re: Still pondering working with hashs

2010-05-11 Thread Jim Gibson
On 5/11/10 Tue May 11, 2010 1:52 PM, "Harry Putnam" scribbled: > Shawn H Corey writes: > >> Harry Putnam wrote: >>> But, is there an easier way? >> >> Invert both hashes and find the keys in both inverses. > > Shawn, hoping to pester you once more about this topic. It is not fair to single

Re: Remove and substitute character in a string with a regex

2010-05-11 Thread C.DeRykus
On May 10, 5:29 am, t.baetz...@bringe.com (Thomas Bätzler) wrote: > Hi Shlomi, > > > use warnings is preferable to the -w flag. > > Not in my book. The command line switch turns on warnings globally, whereas > the "use warnings;" pragma only enables them in the current lexical scope. So > by usin

Re: Still pondering working with hashs

2010-05-11 Thread Shawn H Corey
On 10-05-11 04:52 PM, Harry Putnam wrote: Some selective output first: [...] d1 ./dir1/etc/images/gnus/exit-summ.xpm d2(1) ./dir2/etc/images/gnus/exit-summ.xpm d1 ./dir1/etc/images/gnus/reply.xpm d2(1) ./dir2/etc/images/mail/reply.xpm d2(2) ./di

Re: Still pondering working with hashs

2010-05-11 Thread Harry Putnam
Jim Gibson writes: Harry wrote: >> Shawn, hoping to pester you once more about this topic. Jim G responded: > It is not fair to single out Shawn for help. Just post your question > and hope for a response. Just a manner of speaking, but you're right it does appear to be a little off the wall.

Re: Still pondering working with hashs

2010-05-11 Thread Harry Putnam
Shawn H Corey writes: Oh nice... thanks. Hope I can get to try this out later tonight... I have to go out for a while and can't get to it right now though. The main `for loop' near the end, and really, all of it, looks to be highly portable like the inversion code was I think that little in