When using the range operator, is the list actually created with all the
elements?

For example, if I create a list like (123..456754), does it take up the
same amount of memory as if I actually entered all those in between
numbers?

 

I'm asking because I want to use ranges in a switch statement and they
are large ranges like the above. I don't think I can use >= in the case
section of the switch can I?

 

I think the code below will cause memory problems. Is there a better way
using switch? Or am relegated to using if statements with ">="?

 

my $flag_value = $field_array[9];

    while ($flag_value < 0) {

        switch ($flag_value) {

            case 1                      { $block{"WeightItem"} = "Y";
$flag_value -= 1 }

            case [2, 3]          { $block{"EnterPriceUsed"} = "Y";
$flag_value -= 2 }

            case [4..7]          { $block{"PriceRequired"} = "Y";
$flag_value -= 4 }

            case [8..15]          { $block{"LogItemExcpt"} = "Y";
$flag_value -= 8 }

            case [16..31]         { $block{"CodeFromAlias"} = "Y";
$flag_value -= 16 }

            case [32..255]         { $block{"NoMovement"} = "Y";
$flag_value -= 32 }

            case [256..511]        { $block{"EmpDiscount"} = "Y";
$flag_value -= 256 }

            case [512..1023]        { $block{"KeyedPrice"} = "Y";
$flag_value -= 512 }

            case [1024..2047]       { $block{"NonDiscntable"} = "Y";
$flag_value -= 1024 }

            case [2048..4095]       { $block{"WghtQtyEnt"} = "Y";
$flag_value -= 2048 }

            case [4096..8191]       { $block{"VoidItem"} = "Y";
$flag_value -= 4096 }

            case [8192..16383]       { $block{"RefndEntered"} = "Y";
$flag_value -= 8192 }

            case [16384..32767]      { $block{"LogExcptCond"} = "Y";
$flag_value -= 16384 }

            case [32768..65535]      { $block{"PrhibMultCoup"} = "Y";
$flag_value -= 32768 }

            case [65536..131071]      { $block{"AmtTypeAutoMarkdown"} =
"Y"; $flag_value -= 65536 }

            case [131072..262143]       { $block{"VoidAllItem"} = "Y";
$flag_value -= 131072 }

            case [262144..524287]       { $block{"ErrCorrectVoidItem"} =
"Y"; $flag_value -= 262144 }

            case [524288..33554431]     { $block{"Nsc2PricedItems"} =
"Y"; $flag_value -= 524288 }

            case [33554432..67108863]   { $block{"ItemOnSale"} = "Y";
$flag_value -= 33554432 }

            case [67108864..101711679]  { $block{"ManualWeight"} = "Y";
$flag_value -= 67108864 }       

        }

    }

 

Thanks,

 

Barron

 

Reply via email to