Re: fun programming problem

2009-11-09 Thread Shawn H Corey
Matthew Sacks wrote: > I am unabashedly posting a quiz question I have about regular expressions: > > Looking for suggestions. > > I am thinking > > 1) make the set of regular expressions into one big expression? > 2) search the seach strings, somehow, for common substrings. "acme.org" > would

Re: the classic "which is the fastest way to sort" question

2009-11-09 Thread Uri Guttman
> "PP" == Philip Potter writes: PP> Actually, there is a certain amount of reasoning possible with respect PP> to comparison functions: for example, a Schwartzian Transform will be PP> a win if the key calculation is more expensive than the comparison of PP> keys. that is incorrect.

Re: splitting and replacing characters

2009-11-09 Thread tom smith
On Mon, Nov 9, 2009 at 8:30 PM, tom smith wrote: > > On Mon, Nov 9, 2009 at 10:56 AM, Jim Gibson wrote: > >> However, here is a shortened form using regular expression: >> >> my @output = $line =~ m{ \G (..) .. }gx; >> >> Verify how either of these works when you do not have a multiple of 2 >> c

Re: splitting and replacing characters

2009-11-09 Thread tom smith
On Mon, Nov 9, 2009 at 10:56 AM, Jim Gibson wrote: > However, here is a shortened form using regular expression: > > my @output = $line =~ m{ \G (..) .. }gx; > > Verify how either of these works when you do not have a multiple of 2 > characters in your input. > > It has other problems too: use

fun programming problem

2009-11-09 Thread Matthew Sacks
I am unabashedly posting a quiz question I have about regular expressions: Looking for suggestions. I am thinking 1) make the set of regular expressions into one big expression? 2) search the seach strings, somehow, for common substrings.  "acme.org" would be example. Each hit on acme.org woul

Re: the classic "which is the fastest way to sort" question

2009-11-09 Thread Philip Potter
2009/11/9 Michael Alipio : > Hi, >> >>  Do you need the fastest possible sort? > > I'm not even sure if I really need to worry about all these > sorting techniques. My program just reads a text file > (wordlist). It might be megabyte-sized or probably few > gigabytes (i might also add size checking

Re: splice without the remove

2009-11-09 Thread Dermot
2009/11/9 Shawn H Corey : ... > use Data::Dumper; > > # Make Data::Dumper pretty > $Data::Dumper::Sortkeys = 1; > $Data::Dumper::Indent   = 1; > > # Set maximum depth for Data::Dumper, zero means unlimited > $Data::Dumper::Maxdepth = 0; > > my @array = (1, 4, 6, 9, 2); > my @list = @array[ 1 .. 3 ]

Re: splice without the remove

2009-11-09 Thread Jim Gibson
On 11/9/09 Mon Nov 9, 2009 10:46 AM, "Dermot" scribbled: > Hi, > > I just spent 20mins scratching my head because I didn't read the docs > very closely concerning splice. I had assumed it left the array > intact, its doesn't. I was hoping for a function more akin to substr > where the return w

Re: splice without the remove

2009-11-09 Thread Shawn H Corey
Dermot wrote: > Hi, > > I just spent 20mins scratching my head because I didn't read the docs > very closely concerning splice. I had assumed it left the array > intact, its doesn't. I was hoping for a function more akin to substr > where the return would be the offset -> length of the array but t

splice without the remove

2009-11-09 Thread Dermot
Hi, I just spent 20mins scratching my head because I didn't read the docs very closely concerning splice. I had assumed it left the array intact, its doesn't. I was hoping for a function more akin to substr where the return would be the offset -> length of the array but the value it was working on

Re: the classic "which is the fastest way to sort" question

2009-11-09 Thread Shlomi Fish
On Monday 09 Nov 2009 19:40:29 Uri Guttman wrote: > > "MA" == Michael Alipio writes: > > MA> i'm planning to sort an input file (which was File::Slurp'ed, most > MA> likely megabyte-sized file) in various ways. I did some readings > MA> and learned several methods that people have come

Re: the classic "which is the fastest way to sort" question

2009-11-09 Thread Michael Alipio
Hi,   > >  Do you need the fastest possible sort? I'm not even sure if I really need to worry about all these sorting techniques. My program just reads a text file (wordlist). It might be megabyte-sized or probably few gigabytes (i might also add size checking on this to be safe with File::Sl

Re: splitting and replacing characters

2009-11-09 Thread John W. Krahn
rithu wrote: Hi, Hello, Please help me to split a string as follows.. my $line = "abcdefghijkl" the expected output should be like: ab ef ij The logic is like alternate 2 characters should be removed $ perl -le' my $line = "abcdefghijkl"; my @data = unpack "(a2x2)*", $line; print f

Re: How to catch the DBI module error message

2009-11-09 Thread Parag Kalra
Thanks to All.. It did the trick for me - http://search.cpan.org/~timb/DBI/DBI.pm#$DBI::errstr Cheers, Parag On Mon, Nov 9, 2009 at 6:43 PM, Arun G Nair wrote: > On Mon, Nov 9, 2009 at 6:37 PM, Parag Kalra wrote: > > Hello All, > > >

Re: Monitoring multiple child processes

2009-11-09 Thread Shawn H Corey
Taylor, Andrew (ASPIRE) wrote: > OK, I'm clearly being dense here then. My understanding was that the > "$?" contained the status of the pid returned by waidpid. > > If waitpid returned a pid from some other process (i.e. not one of my > children) that had failed (i.e return status other than 0

Re: splitting and replacing characters

2009-11-09 Thread Robert Wohlfarth
On Mon, Nov 9, 2009 at 7:03 AM, rithu wrote: > Please help me to split a string as follows.. > > my $line = "abcdefghijkl" > > the expected output should be like: > > ab > ef > ij > > > The logic is like alternate 2 characters should be removed > Will a "for" loop work for your needs? The on

Re: splitting and replacing characters

2009-11-09 Thread Jim Gibson
On 11/9/09 Mon Nov 9, 2009 5:03 AM, "rithu" scribbled: > Hi, > > Please help me to split a string as follows.. > > my $line = "abcdefghijkl" > > the expected output should be like: > > ab > ef > ij > > > The logic is like alternate 2 characters should be removed split would not be th

Re: Clarification needed on metacharacters

2009-11-09 Thread Uri Guttman
> "PN" == Pierre Nugues writes: PN> I am wondering on some metacharacters in regular expressions. PN> According to Wall et al. (2000, p. 158), there are 12 metacharacters: PN> * + ? . \ | ( ) [ { ^ $ PN> On the other hand, the Perl regular expressions quick start PN> (http://perldoc

Re: the classic "which is the fastest way to sort" question

2009-11-09 Thread Philip Potter
2009/11/9 Michael Alipio : > Hi, > > i'm planning to sort an input file (which was File::Slurp'ed, most likely > megabyte-sized file) in various ways. I did some readings and learned several > methods > that people have come up with in recent years. So to summarize, the default > sort is fast (u

Re: the classic "which is the fastest way to sort" question

2009-11-09 Thread Uri Guttman
> "MA" == Michael Alipio writes: MA> i'm planning to sort an input file (which was File::Slurp'ed, most MA> likely megabyte-sized file) in various ways. I did some readings MA> and learned several methods that people have come up with in MA> recent years. So to summarize, the default

RE: Monitoring multiple child processes

2009-11-09 Thread Taylor, Andrew (ASPIRE)
> >> my $kid = waitpid($child_pid, 0); >> >> redo if $kid != $child_pid; # So goes back to start of loop from here >> >> unless( 0==$? ) # And never performs this test >> { >> die ("Oh No! An external process has failed!!\n"); >> } >> } >> >> >> That makes most sense to me but

splitting and replacing characters

2009-11-09 Thread rithu
Hi, Please help me to split a string as follows.. my $line = "abcdefghijkl" the expected output should be like: ab ef ij The logic is like alternate 2 characters should be removed -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@

Clarification needed on metacharacters

2009-11-09 Thread Pierre Nugues
Hello, I am wondering on some metacharacters in regular expressions. According to Wall et al. (2000, p. 158), there are 12 metacharacters: * + ? . \ | ( ) [ { ^ $ On the other hand, the Perl regular expressions quick start (http://perldoc.perl.org/perlrequick.html ) cites 14 metacharacters:

the classic "which is the fastest way to sort" question

2009-11-09 Thread Michael Alipio
Hi, i'm planning to sort an input file (which was File::Slurp'ed, most likely megabyte-sized file) in various ways. I did some readings and learned several methods that people have come up with in recent years. So to summarize, the default sort is fast (uses quick sort), explicit (using sub) is

Re: regex question

2009-11-09 Thread Jay Savage
On Mon, Nov 9, 2009 at 10:25 AM, axr0284 wrote: > Hi, >  I am completely stumped with how to proceed with this. > I have a program where the user inputs a path to a file. This is under > windows xp > > The path can be relative > ..\..\..\synthesis\int_code.psm > .\program\synthesis\int_code.psm >

regex question

2009-11-09 Thread axr0284
Hi, I am completely stumped with how to proceed with this. I have a program where the user inputs a path to a file. This is under windows xp The path can be relative ..\..\..\synthesis\int_code.psm .\program\synthesis\int_code.psm or absolute c:\command\tool\program\synthesis\int_code.psm I do

Re: Net::FTP fails when invoked from browser

2009-11-09 Thread Peter Scott
On Sat, 07 Nov 2009 09:51:49 -0800, Boman wrote: > Have a simple script to FTP all files in one dir to a Solaris box. > Script runs fine when invoked from command line. However, when invoked > from browser (simple html form with one button that calls the .pl > script), only some files get FTPd. The

Re: Monitoring multiple child processes

2009-11-09 Thread Shawn H Corey
Taylor, Andrew (ASPIRE) wrote: > Am I rignt in assuming the redo should be before the $? test (in case > this rogue pid has returned a status other than 0)?, like so: > > foreach my $child_pid (@pids) > { > waitpid($child_pid, 0); Remove this line. You are doing waitpid twice. > my $kid = w

RE: Monitoring multiple child processes

2009-11-09 Thread Taylor, Andrew (ASPIRE)
>Taylor, Andrew (ASPIRE) wrote: >> Hello >> >> I have a script that, much like the Little Old Lady who lived in a shoe, >> has so many children it's not sure what to do. >> >> Basically, the script does some stuff, then kicks off multiple copies of >> an external process that all run in parallel.

AW: How to catch the DBI module error message

2009-11-09 Thread Thomas Bätzler
Parag Kalra asked: [DBI] > However I just wanted to know if there is a way to catch this error > message through some standard DBI variable so that I can print it in a log > file You can use the errstr() class and instance methods to access the last error message. In order to stop DBI from pri

Re: How to catch the DBI module error message

2009-11-09 Thread Dermot
2009/11/9 Parag Kalra : > Hello All, Hello, > This is my first post here. Are you sure about that? I have a vague recollection of a question you asked about "Optimizing File handling operations" then of course there was the "My name is Larry Wall" for which I apologise :) > I am executing a Pe

How to catch the DBI module error message

2009-11-09 Thread Parag Kalra
Hello All, This is my first post here. I am executing a Perl script which makes use of 'DBI' module. I am performing a select operation on a table through the Perl script and I am getting following error on the console: DBD::ODBC::st execute failed: [Oracle][ODBC][Ora]ORA-00942: table or view d

Re: Monitoring multiple child processes

2009-11-09 Thread Shawn H Corey
Taylor, Andrew (ASPIRE) wrote: > Hello > > I have a script that, much like the Little Old Lady who lived in a shoe, > has so many children it's not sure what to do. > > Basically, the script does some stuff, then kicks off multiple copies of > an external process that all run in parallel. It the

Monitoring multiple child processes

2009-11-09 Thread Taylor, Andrew (ASPIRE)
Hello I have a script that, much like the Little Old Lady who lived in a shoe, has so many children it's not sure what to do. Basically, the script does some stuff, then kicks off multiple copies of an external process that all run in parallel. It then has to wait until all of them have complete