Barron Snyder (CE CEN) wrote:
> When using the range operator, is the list actually created with all the
> elements?
It depends. :-) In general, yes it does. See the "Range Operators" section
of perlop:
perldoc perlop
> 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?
Yes.
> 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 ">="?
It looks like you can use bitwise operators:
my $flag_value = $field_array[ 9 ];
$block{ WeightItem } = 'Y' if $flag_value & 0x00000001;
$block{ EnterPriceUsed } = 'Y' if $flag_value & 0x00000002;
$block{ PriceRequired } = 'Y' if $flag_value & 0x00000004;
$block{ LogItemExcpt } = 'Y' if $flag_value & 0x00000008;
$block{ CodeFromAlias } = 'Y' if $flag_value & 0x00000010;
$block{ NoMovement } = 'Y' if $flag_value & 0x00000020;
$block{ EmpDiscount } = 'Y' if $flag_value & 0x00000100;
$block{ KeyedPrice } = 'Y' if $flag_value & 0x00000200;
$block{ NonDiscntable } = 'Y' if $flag_value & 0x00000400;
$block{ WghtQtyEnt } = 'Y' if $flag_value & 0x00000800;
$block{ VoidItem } = 'Y' if $flag_value & 0x00001000;
$block{ RefndEntered } = 'Y' if $flag_value & 0x00002000;
$block{ LogExcptCond } = 'Y' if $flag_value & 0x00004000;
$block{ PrhibMultCoup } = 'Y' if $flag_value & 0x00008000;
$block{ AmtTypeAutoMarkdown } = 'Y' if $flag_value & 0x00010000;
$block{ VoidAllItem } = 'Y' if $flag_value & 0x00020000;
$block{ ErrCorrectVoidItem } = 'Y' if $flag_value & 0x00040000;
$block{ Nsc2PricedItems } = 'Y' if $flag_value & 0x00080000;
$block{ ItemOnSale } = 'Y' if $flag_value & 0x02000000;
$block{ ManualWeight } = 'Y' if $flag_value & 0x04000000;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>