Re: readdir formulated badly? gives wrong count

2007-12-01 Thread reader
John W.Krahn <[EMAIL PROTECTED]> writes: > On Friday 30 November 2007 22:47, [EMAIL PROTECTED] wrote: > > Sorry for taking so long to reply but I was mulling it over while > eating cold pizza and watching NCAAF. You don't specify the exact file > names so I will assume that they match the patte

Re: regular expression question

2007-12-01 Thread John W . Krahn
On Saturday 01 December 2007 18:16, Eric Krause wrote: > > Hello all, Hello, > I have a string like: > 1xxx1111xx11x1 > > I would like to replace the 1's with the total of 1's like this: > 5xxx26xx2x1 $ perl -le' $_ = q[1xxx1111xx11x1]; print; s/(1+)/@{[(

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread John W . Krahn
On Friday 30 November 2007 22:47, [EMAIL PROTECTED] wrote: Sorry for taking so long to reply but I was mulling it over while eating cold pizza and watching NCAAF. You don't specify the exact file names so I will assume that they match the pattern /\A\d+\z/ which is what you use when you copy t

Re: regular expression question

2007-12-01 Thread Tom Phoenix
On 12/1/07, Eric Krause <[EMAIL PROTECTED]> wrote: > I have a string like: > 1xxx1111xx11x1 > > I would like to replace the 1's with the total of 1's like this: > 5xxx26xx2x1 Hmmm Smells like homework. What have you tried so far? Your missing pieces of the puzzle may

regular expression question

2007-12-01 Thread Eric Krause
Hello all, I have a string like: 1xxx1111xx11x1 I would like to replace the 1's with the total of 1's like this: 5xxx26xx2x1 Can anyone please help? -Eric -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.o

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread reader
"Tom Phoenix" <[EMAIL PROTECTED]> writes: > On 12/1/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> John W.Krahn <[EMAIL PROTECTED]> writes: >> > perldoc -f rewinddir >> >> Is that faster or anything than using a second opendir? > > Is it faster? What did you find out when you benchmarked both

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread Rob Dixon
Matthew Whipple wrote: The for loop won't execute if it has nothing through which to iterate. On my system the for won't execute with an empty list, but will once when the array is undefined. Changing the above to 'if (defined(@DirContent)) {' would be a bit clearer. Now what would you mean

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread Tom Phoenix
On 12/1/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > John W.Krahn <[EMAIL PROTECTED]> writes: > > perldoc -f rewinddir > > Is that faster or anything than using a second opendir? Is it faster? What did you find out when you benchmarked both ways of coding it? In any case, when you're readin

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread John W . Krahn
On Saturday 01 December 2007 17:25, Matthew Whipple wrote: > > [EMAIL PROTECTED] wrote: > > > > kens <[EMAIL PROTECTED]> writes: > > > >> This test add nothing. The for loop will fail if there is no > >> content > >> > >>> if ($DirContent[0]){ > > > > Checking to make sure there are in fact numbere

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread John W . Krahn
On Saturday 01 December 2007 16:20, [EMAIL PROTECTED] wrote: > > John W.Krahn <[EMAIL PROTECTED]> writes: > > > > perldoc -f rewinddir > > Is that faster or anything than using a second opendir? I don't know, you'd have to use Benchmark to test it. (In my defense you only asked if it was possibl

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread Matthew Whipple
[EMAIL PROTECTED] wrote: > Thanks for taking time to respong and go clear thru the script bit by > bit. > > kens <[EMAIL PROTECTED]> writes: > > [...] > > >> # The following lines are your friend >> use strict; >> use warnings; >> > > I've seen that before but didn't understand why. > > T

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread reader
John W.Krahn <[EMAIL PROTECTED]> writes: > perldoc -f rewinddir Is that faster or anything than using a second opendir? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: How can I sort files by timestamp without slurping?

2007-12-01 Thread Rob Dixon
icarus wrote: Thanks Rob and Martin for your inputs. I found a solution to my problem. I'm posting it here for whoever might need it. I'm sure there's a faster solution out there but this will do just fine. I had to put the files in an array. :( The reason is that you cannot sort a scalar [ or

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread John W . Krahn
On Saturday 01 December 2007 08:30, [EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] writes: > >> The main problem, I believe, is that you are using a stale > >> directory handle. closedir (in main) and opendir here. > > > > Ha... and that was the problem... turns out it doesn't need to be > > moved.

Re: How can I sort files by timestamp without slurping?

2007-12-01 Thread Matthew Whipple
icarus wrote: > Thanks Rob and Martin for your inputs. > > I found a solution to my problem. I'm posting it here for whoever > might need it. I'm sure there's a faster solution out there but this > will do just fine. > I had to put the files in an array. :( > The reason is that you cannot sort a

Re: How can I sort files by timestamp without slurping?

2007-12-01 Thread John W . Krahn
On Friday 30 November 2007 11:04, icarus wrote: > Thanks Rob and Martin for your inputs. > > I found a solution to my problem. Well, at least part of the solution. > I'm posting it here for whoever might need it. I would advise that no one else *needs* this solution. :( > I'm sure there's a fa

Re: Can't understand this.

2007-12-01 Thread AY
On Nov 30, 12:21 am, [EMAIL PROTECTED] (John W . Krahn) wrote: > On Thursday 29 November 2007 06:29, AY wrote: > > > > > I'm not sure what this piece of code does: Infact it is getting a > > database query and iterating ... > > > my %temp; > > > while ( my %row = $dbproc->dbnextrow(1) ){ > > $dbpro

Re: login and download a file from a website

2007-12-01 Thread Eric Krause
GunabalanS wrote: hai i want to login and down load a page from a web sire using perl Here's a web page that helped me figure it all out. http://www.ibm.com/developerworks/web/library/wa-perlsecure.html Cheers. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail:

Re: Question abount counting the total number of lines and put to an variable?

2007-12-01 Thread Marco
Hi Patmarbidon, Thanks for your help. you do help me a lot...thanks... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread reader
[EMAIL PROTECTED] writes: >> The main problem, I believe, is that you are using a stale directory >> handle. closedir (in main) and opendir here. > > Ha... and that was the problem... turns out it doesn't need to be > moved. Once the typeo is corrected to closedir(DIR); it works, with > no reopen

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread reader
Thanks for taking time to respong and go clear thru the script bit by bit. kens <[EMAIL PROTECTED]> writes: [...] > # The following lines are your friend > use strict; > use warnings; I've seen that before but didn't understand why. The `warnings' part is clear enough but doesn't the -w flag

Re: How can I sort files by timestamp without slurping?

2007-12-01 Thread icarus
Thanks Rob and Martin for your inputs. I found a solution to my problem. I'm posting it here for whoever might need it. I'm sure there's a faster solution out there but this will do just fine. I had to put the files in an array. :( The reason is that you cannot sort a scalar [ or scalar context

Re: test if nth sign of a string is a number

2007-12-01 Thread [EMAIL PROTECTED]
On 1 Dez., 04:20, [EMAIL PROTECTED] (Jeff Pang) wrote: > On Nov 30, 2007 10:56 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Hello, > > > how can I test if the nth (n=2) sign of a string is a number [0-9]? > > Thank you. > > Hello, > > Given you have this string: $str = "a9d0"; > > you can

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread kens
On Dec 1, 1:47 am, [EMAIL PROTECTED] wrote: > Sorry to plop so much shabby code up here but I think I've stared at > this a little too long and am now incapable of catching my error. > > This started out as just a helper script to help solve this problem: > > Needing to cp files with number names f

Re: login and download a file from a website

2007-12-01 Thread Jeff Pang
On Dec 1, 2007 11:28 AM, GunabalanS <[EMAIL PROTECTED]> wrote: > hai > i want to login and down load a page from a web sire using perl > > the answer is: use a module from CPAN like WWW::Mechanize and code it by yourself. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mai

login and download a file from a website

2007-12-01 Thread GunabalanS
hai i want to login and down load a page from a web sire using perl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: test if nth sign of a string is a number

2007-12-01 Thread Dr.Ruud
"Jeff Pang" schreef: > guba: >> how can I test if the nth (n=2) sign of a string is a number [0-9]? > > Given you have this string: $str = "a9d0"; > you can check if the 2nd character is a number or not by: > my $c = substr($str,1,1); > print ($c=~/[0-9]/) ? "a number" : "not a number";