[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Tie::SubstrHash -- anybody??



At 3:04 PM -0700 10/5/2000, Bruce Van Allen wrote:
>At 1:22 PM 10/5/00, Linc Madison wrote:
>>>$hashsize = 114_862;		# arbitrary values from my data set
>.................^
>
>>>	$key1 = $i + 100_000;		# fix to uniform 6-digit numbers
>........................^
>
>I've watched this discussion, but not being familiar with 
>Tie::SubstrHash, haven't spoken up until now. What kind of numbers 
>are 114_862 and 100_000? If they're not really numerical, then 
>testing and incrementing won't give the results your code seems to 
>want. I imagine that this could cause your hash to have only one 
>key/value pair...
>
>Why not 114862, 100000?

They're syntactically equivalent. The underscores in numerical 
constants are for legibility to humans, but are disregarded by Perl.

For instance,

print "It's true!\n" if (114_862 == 114862);

It only works for numeric literals, though. For example,

print ( ("114_862" + 1 == 114863) ? "Same\n" : "Different\n" );

will result in "Different\n", because the string "114_862" converts 
to the numeric value 114, not 114862.

Look under "numeric literals" in the Perl documentation; page 39 if 
you have "Programming Perl (2nd edition)" from O'Reilly.

-- 
Linc Madison  *  San Francisco, CA  *  LincPerl@LincMad.com
NO SPAM: California Bus & Prof Code Section 17538.45 applies!

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org