RE: how to look back past hour

2008-04-01 Thread Thomas Bätzler
Richard Lee <[EMAIL PROTECTED]> asked: > What is the best way to indicate past hour from current time > without using a module? [...] #!/usr/bin/perl -w use strict; printf "%d:%02d to %d:%02d\n", (localtime time - 3600 )[2,1], (localtime time)[2,1]; __END__ > my $time = localtime; > my @tim

Re: how to look back past hour

2008-04-01 Thread Chas. Owens
On Wed, Apr 2, 2008 at 2:24 AM, Jeff Pang <[EMAIL PROTECTED]> wrote: > On 4/2/08, Chas. Owens <[EMAIL PROTECTED]> wrote: > > On Wed, Apr 2, 2008 at 2:02 AM, Jeff Pang <[EMAIL PROTECTED]> wrote: > > > On 4/2/08, Richard Lee <[EMAIL PROTECTED]> wrote: > > > > What is the best way to indicate past

Re: how to look back past hour

2008-04-01 Thread Jeff Pang
On 4/2/08, Chas. Owens <[EMAIL PROTECTED]> wrote: > On Wed, Apr 2, 2008 at 2:02 AM, Jeff Pang <[EMAIL PROTECTED]> wrote: > > On 4/2/08, Richard Lee <[EMAIL PROTECTED]> wrote: > > > What is the best way to indicate past hour from current time without > > > using a module? > > > > > > so if it's

Re: how to look back past hour

2008-04-01 Thread John W. Krahn
Richard Lee wrote: What is the best way to indicate past hour from current time without using a module? so if it's 12:00, then 11:00-12:00 if it's 17:30 then 16:30 to 17:30 if it's 00:30 then 23:30 to 00:30 I wrote a below program and works but there has to be a better and easier(not sure i

Re: how to look back past hour

2008-04-01 Thread Chas. Owens
On Wed, Apr 2, 2008 at 2:02 AM, Jeff Pang <[EMAIL PROTECTED]> wrote: > On 4/2/08, Richard Lee <[EMAIL PROTECTED]> wrote: > > What is the best way to indicate past hour from current time without > > using a module? > > > > so if it's 12:00, then 11:00-12:00 > > > > I'd prefer using POSIX modul

Re: how to look back past hour

2008-04-01 Thread Jeff Pang
On 4/2/08, Richard Lee <[EMAIL PROTECTED]> wrote: > What is the best way to indicate past hour from current time without > using a module? > > so if it's 12:00, then 11:00-12:00 > I'd prefer using POSIX module since it's a built-in perl module. The code would be simple, use strict; use POSIX 'str

how to look back past hour

2008-04-01 Thread Richard Lee
What is the best way to indicate past hour from current time without using a module? so if it's 12:00, then 11:00-12:00 if it's 17:30 then 16:30 to 17:30 if it's 00:30 then 23:30 to 00:30 I wrote a below program and works but there has to be a better and easier(not sure if I want easier as I

Re: sort without ignoring hyphens

2008-04-01 Thread tc314
On Mar 29, 3:19 pm, [EMAIL PROTECTED] (John W. Krahn) wrote: > [EMAIL PROTECTED] wrote: > > When I do string comparisons in perl the strings seem to ignore the > > embedded hyphens. > > I want to sort strings assuming the 'dictionary' order of the chars is > > ASCII order: hypen, 0-9, A-Z. > > It a

Re: sort without ignoring hyphens

2008-04-01 Thread Dr.Ruud
[EMAIL PROTECTED] schreef: > John W. Krahn: >> It appears to work in Perl: >> >> $ perl -le'@x = qw[22 2-2 2-3 23 21]; print for sort @x' >> 2-2 >> 2-3 >> 21 >> 22 >> 23 > > I'm looking for the perl way of comparing strings. > > Your posted code 'diff says memory exhausted need help with perl >

Re: algorithm/permute.pm

2008-04-01 Thread sisyphus
> I did the following: > perl Makefile.PL PREFIX=/u/basappas/local/perl/Algorithm-Permute-0.06 That's probably where you've got the Algorithm-Permute source - I'm not so sure it's a good idea to install the module into the source folder, but if you want to do that then next run 'make test', follow

Re: how to extract the last digit

2008-04-01 Thread Chas. Owens
On Tue, Apr 1, 2008 at 5:17 PM, yitzle <[EMAIL PROTECTED]> wrote: > On Tue, Apr 1, 2008 at 4:03 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: > > yitzle wrote: > > > Is there some way to convert it (a string/scalar) to an array? > > > > Is this what you mean? > > > > my $string = 'ABCDEF'; > >

Re: how to extract the last digit

2008-04-01 Thread Chas. Owens
2008/4/1 Jay Savage <[EMAIL PROTECTED]>: snip > my ($last) = $number =~ /.*(\d)/; > > Let Perl worry about what is and isn't a digit. snip Unfortunately, with the rise of UNICODE, \d is no longer what one expects* ([0-9]). It now includes all characters marked as digits in UNICODE. This inc

Re: how to extract the last digit

2008-04-01 Thread yitzle
On Tue, Apr 1, 2008 at 4:03 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: > yitzle wrote: > > Is there some way to convert it (a string/scalar) to an array? > > Is this what you mean? > > my $string = 'ABCDEF'; > my @string = split '', $string; > > > > Rob I suppose. That can be used to extract th

Re: how to extract the last digit

2008-04-01 Thread Rob Dixon
yitzle wrote: > Is there some way to convert it (a string/scalar) to an array? Is this what you mean? my $string = 'ABCDEF'; my @string = split '', $string; Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: how to extract the last digit

2008-04-01 Thread yitzle
Is there some way to convert it (a string/scalar) to an array? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: how to extract the last digit

2008-04-01 Thread Jay Savage
On Tue, Apr 1, 2008 at 11:09 AM, Rob Dixon <[EMAIL PROTECTED]> wrote: [snip] > > my ($lastdigit) = $number =~ /.*([0-9])/; > > gives you the last decimal digit (even if there are non-decimals after > it). > Better yet: my ($last) = $number =~ /.*(\d)/; Let Perl worry about what is and

Re: how to extract the last digit

2008-04-01 Thread Rob Dixon
John W. Krahn wrote: > [EMAIL PROTECTED] wrote: >> Hi, > > Hello, > >> How do I extract the last digit of a number? example I only want the digit 9 >> from the number 19. >> >> my $number = 19; > > my $last_digit = chop $number; Yes, although it's important to note that that method removes the

Re: how to extract the last digit

2008-04-01 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hi, Hello, How do I extract the last digit of a number? example I only want the digit 9 from the number 19. my $number = 19; my $last_digit = chop $number; John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools

Re: how to extract the last digit

2008-04-01 Thread Rob Dixon
[EMAIL PROTECTED] wrote: > > How do I extract the last digit of a number? example I only want the digit 9 from the number 19. > > my $number = 19; There are a few ways. my $lastdigit = substr $number, -1; gives you the last character in the string my $lastdigit = $number % 10; gives you t

how to extract the last digit

2008-04-01 Thread itshardtogetone
Hi, How do I extract the last digit of a number? example I only want the digit 9 from the number 19. my $number = 19;

Re: cant find locally installed module

2008-04-01 Thread Rob Dixon
Sharan Basappa wrote: > > I have installed permute module locally and added the path to my script. > However, perl fails to find the module. > > The script: > #!/usr/bin/perl > use lib "/u/basappas/local/perl/Algorithm-Permute-0.06"; > use Algorithm::Permute; > my @array = (1..9); > Algorithm::Per

cant find locally installed module

2008-04-01 Thread Sharan Basappa
I have installed permute module locally and added the path to my script. However, perl fails to find the module. The script: #!/usr/bin/perl use lib "/u/basappas/local/perl/Algorithm-Permute-0.06"; use Algorithm::Permute; my @array = (1..9); Algorithm::Permute::permute { print "@array\n" } @array;

Re: copy ffiles and directories recursively

2008-04-01 Thread alok nath
Hi, There is a small problem now : It now copies the files as directories : #!/usr/bin/perl $startDir = q{c:\test}; $newDir = q{c:\new}; &myReadDir($startDir); exit 0; sub myReadDir { my ($dir) = @_; print "\n\nProcessing $dir \n" ; my (@di

Re: copy ffiles and directories recursively

2008-04-01 Thread John W. Krahn
alok nath wrote: Hi, Hello, I wanted to recursively copy the contents of a directory(both directory and files) from one folder to the other. The below code does only copy of directories but leaves behind files. Can anybody help me how to do that ? http://search.cpan.org/~dmuey/File-Copy-Rec

Re: copy ffiles and directories recursively

2008-04-01 Thread Jeff Pang
On 4/1/08, alok nath <[EMAIL PROTECTED]> wrote: > Hi, > I wanted to recursively copy the contents of a directory(both directory and > files) from one folder to the other. use File::Copy from CPAN. > The below code does only copy of directories but leaves behind files. >@dirs=grep {!(

copy ffiles and directories recursively

2008-04-01 Thread alok nath
Hi, I wanted to recursively copy the contents of a directory(both directory and files) from one folder to the other. The below code does only copy of directories but leaves behind files. Can anybody help me how to do that ? Regards, Alok #!/usr/bin/perl $startDir = q{c:\test}; $newDi