Re: help with a regex

2009-07-17 Thread John W. Krahn
Jenn G. wrote: Hello, Hello, I'm not sure if the syntax below is correct: next if /\/0$|^127\./; ( the regex means when meet something like 192.168.1.0/0 or 127.0.0.1 it will be next.) Or do I need to use () to enclose the char at both sides of the "|" ? next if /(\/0$)|(^127\.)/; No,

help with a regex

2009-07-17 Thread Jenn G.
Hello, I'm not sure if the syntax below is correct: next if /\/0$|^127\./; ( the regex means when meet something like 192.168.1.0/0 or 127.0.0.1 it will be next.) Or do I need to use () to enclose the char at both sides of the "|" ? next if /(\/0$)|(^127\.)/; Please help, thanks! Regards.

Re: Using a string as a hash (symbolic ref)

2009-07-17 Thread Steve Bertrand
Uri Guttman wrote: >> "SB" == Steve Bertrand writes: > >> again, what is unlike? i now guess it is from a test module. does it > >> take a regex as an arg? > > SB> unlike is from Test::More. Both unlike and like take a regex as it's > SB> second parameter. I took a quick look at the

Re: Using a string as a hash (symbolic ref)

2009-07-17 Thread Uri Guttman
> "SB" == Steve Bertrand writes: SB> Uri Guttman wrote: >> SB> for my $known_type (@known_types) { >> SB> unless (exists $typedefs{$known_type} ) { >> >> again, you don't need exists there. since your dispatch table's values >> are always code refs so they will always be tr

Re: Using a string as a hash (symbolic ref)

2009-07-17 Thread Steve Bertrand
Uri Guttman wrote: >> "SB" == Steve Bertrand writes: > > SB> In all honesty, I think I'm learning more about Perl (and my own > SB> programs) writing the tests than I do when I'm writing the programs > SB> themselves. (Same goes for keeping up with the documentation!). > > coding is co

Re: Using a string as a hash (symbolic ref)

2009-07-17 Thread Uri Guttman
> "SB" == Steve Bertrand writes: SB> In all honesty, I think I'm learning more about Perl (and my own SB> programs) writing the tests than I do when I'm writing the programs SB> themselves. (Same goes for keeping up with the documentation!). coding is coding and the more you do the mor

Re: Using a string as a hash (symbolic ref)

2009-07-17 Thread Steve Bertrand
Uri Guttman wrote: >> "SB" == Steve Bertrand writes: > > SB> I create %typedefs hash, where each key is a name which has a value of a > SB> coderef that simply creates and returns a hash. Then: > > SB> my @data_types = $vardb->is_type(); > SB> my @missing_types; > > SB> for (@data

Re: bug in perl

2009-07-17 Thread Telemachus
On Fri Jul 17 2009 @ 3:18, Octavian Rasnita wrote: > From: "Shawn H. Corey" >> Octavian Rasnita wrote: >>> Well, in PHP that calculation is made well, so I think there is a bug >>> in perl. >>> >> >> No, it's not. PHP rounds off the number before printing. In Perl: >> >> printf "%.2f", $x; >>

Re: Using a string as a hash (symbolic ref)

2009-07-17 Thread Uri Guttman
> "SB" == Steve Bertrand writes: SB> I create %typedefs hash, where each key is a name which has a value of a SB> coderef that simply creates and returns a hash. Then: SB> my @data_types = $vardb->is_type(); SB> my @missing_types; SB> for (@data_types) { use named vars instead of

Re: Using a string as a hash (symbolic ref)

2009-07-17 Thread Steve Bertrand
Shawn H. Corey wrote: > Steve Bertrand wrote: >> I also really like your suggestion of putting the hashes within a sub. >> This will prevent the reset of ALL the data types each time new tests >> are run. >> > > You may want to look at dclone() from Storable. It clones deeply nested > structures.

Re: Using a string as a hash (symbolic ref)

2009-07-17 Thread Shawn H. Corey
Steve Bertrand wrote: I also really like your suggestion of putting the hashes within a sub. This will prevent the reset of ALL the data types each time new tests are run. You may want to look at dclone() from Storable. It clones deeply nested structures. #!/usr/bin/perl use strict; use w

Re: Using a string as a hash (symbolic ref)

2009-07-17 Thread Steve Bertrand
Uri Guttman wrote: >> "SB" == Steve Bertrand writes: > > SB> I make these hashes available globally, initially as undef. I have a > > there is no such thing as an undef hash. it is either empty or > not. undef is a single value and hashes are always in pairs. never do > undef %hash or even

Re: Using a string as a hash (symbolic ref)

2009-07-17 Thread Uri Guttman
> "SB" == Steve Bertrand writes: SB> I make these hashes available globally, initially as undef. I have a there is no such thing as an undef hash. it is either empty or not. undef is a single value and hashes are always in pairs. never do undef %hash or even worse %hash = undef (the latter

Using a string as a hash (symbolic ref)

2009-07-17 Thread Steve Bertrand
Hi everyone, In the test files I have that are used for testing the properties and qualities of a data/type validator, I make these hashes available globally, initially as undef. I have a reset() function that defines and populates the data types (all hashes) to a default state with default value

Re: perl query

2009-07-17 Thread John W. Krahn
Rajini Naidu wrote: On Tue, Jul 14, 2009 at 5:02 PM, John W. Krahn wrote: Rajini Naidu wrote: I have the below commands in the script. `$swlist -l bundle -a revision -a architecture -s $t | $grep $n >> $log_our_depot`; `$swlist -l bundle -a revision -a architecture -s $t | $grep $n >> $log

Re: bug in perl?

2009-07-17 Thread Octavian Rasnita
From: "Shawn H. Corey" Octavian Rasnita wrote: Well, in PHP that calculation is made well, so I think there is a bug in perl. No, it's not. PHP rounds off the number before printing. In Perl: printf "%.2f", $x; or $x = sprintf "%.2f", $x; Ok, thank you all for your help. Octavian

Re: bug in perl?

2009-07-17 Thread Shawn H. Corey
Octavian Rasnita wrote: Well, in PHP that calculation is made well, so I think there is a bug in perl. No, it's not. PHP rounds off the number before printing. In Perl: printf "%.2f", $x; or $x = sprintf "%.2f", $x; -- Just my 0.0002 million dollars worth, Shawn Programming is a

Re: bug in perl?

2009-07-17 Thread Bob goolsby
The basic issue is one of representation -- your represent numbers in base 10 (decimal); the Machine represents numbers in base 2 (binary). When you (or the Machine) translates between bases, there may be some loss in precision -- a number that is finite, terminating fraction in base19 (0.78, for

Re: bug in perl?

2009-07-17 Thread Octavian Rasnita
From: "Thomas Bätzler" Octavian Rasnita asked: I have tried the following calculation with ActivePerl 5.10.0 build 1004 under Windows XP Pro: print 0.79 - 0.798; And it gave the following result: -0.00801 which is obviously wrong. No, it isn't. Welcome to the wonderful world o

AW: bug in perl?

2009-07-17 Thread Thomas Bätzler
Paul Johnson wrote: > On Fri, Jul 17, 2009 at 12:26:58PM +0200, Thomas Bätzler wrote: > > Octavian Rasnita asked: > > > I have tried the following calculation with ActivePerl 5.10.0 build > > > 1004 under Windows XP Pro: > > > > > > print 0.79 - 0.798; > > > > > > And it gave the following result

Re: bug in perl?

2009-07-17 Thread Shawn H. Corey
Paul Johnson wrote: On Fri, Jul 17, 2009 at 12:26:58PM +0200, Thomas Bätzler wrote: Octavian Rasnita asked: I have tried the following calculation with ActivePerl 5.10.0 build 1004 under Windows XP Pro: print 0.79 - 0.798; And it gave the following result: -0.00801 which

Re: bug in perl?

2009-07-17 Thread Paul Johnson
On Fri, Jul 17, 2009 at 12:26:58PM +0200, Thomas Bätzler wrote: > Octavian Rasnita asked: > > I have tried the following calculation with ActivePerl 5.10.0 build 1004 > > under Windows XP Pro: > > > > print 0.79 - 0.798; > > > > And it gave the following result: > > -0.00801 > > > >

AW: bug in perl?

2009-07-17 Thread Thomas Bätzler
Octavian Rasnita asked: > I have tried the following calculation with ActivePerl 5.10.0 build 1004 > under Windows XP Pro: > > print 0.79 - 0.798; > > And it gave the following result: > -0.00801 > > which is obviously wrong. No, it isn't. Welcome to the wonderful world of machine

bug in perl?

2009-07-17 Thread Octavian Rasnita
Hi, I have tried the following calculation with ActivePerl 5.10.0 build 1004 under Windows XP Pro: print 0.79 - 0.798; And it gave the following result: -0.00801 which is obviously wrong. It doesn't matter too much the reasons, but is there a better way for doing such math calc

Re: Fw: Modifiers on the right side of the statement

2009-07-17 Thread Soham Das
Thank You for correcting me, indeed binding operator has higher precedence than other operators. I apologise for making a hotch potch out of the entire solution. I confused it thinking you posted this issue, and didnt see that you were the one answering it. Yes, your answer is much better. Th