Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: Re: Finding missing elements in a sequence (code)

by deprecated (Priest)
on Nov 06, 2001 at 21:38 UTC ( #123633=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Finding missing elements in a sequence (code)
in thread Finding missing elements in a sequence (code)

Wonderful! This works. Can you please go into a little more detail as to how this works? I am not sure how:

"00010" + 0
DWIM's.

brother dep

--
Laziness, Impatience, Hubris, and Generosity.


Comment on Re: Re: Re: Finding missing elements in a sequence (code)
Download Code
Re: Re: Re: Re: Finding missing elements in a sequence (code)
by clemburg (Curate) on Nov 06, 2001 at 22:07 UTC

    Adding 0 to the string "00001" forces the string to be interpreted as a number.

    In your code, when you say:

    my %isthere = map { $_ => 0 } ($low..$high);

    You force "00001" to be treated as a number, too. What *is* interesting is *why* "00001" is treated as a number, since there is also the possibility of doing "aaa" ... "zzz" and having it work, too. So why does "00001" end up being treated as "1" by the ".." operator? Probably the perl interpreter looks at your $low and $high and decides they look like numbers.

    BTW, you should not do this $low .. $high stuff - it can hang you badly if $low and $high end up to be interpreted as strings.

    At least use int($low) .. int($high), to force $low and $high to be interpreted as numbers.

    Christian Lemburg
    Brainbench MVP for Perl
    http://www.brainbench.com

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://123633]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2014-08-23 17:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (175 votes), past polls