The following worked for me, but of course I did not duplicate the uint_16. Maybe the return of $obj->VideoArchitecture needs to be unpacked? [ $n = unpack('S',$obj->VideoArchitecture) ] 'S' represents an unsigned short 16-bit int.
print "Enter a number: ";
$n = <>;
chomp($n);
for ($n) {
/^(1)$/ && do { $arch = "Other", last };
/^(2)$/ && do { $arch = "Unknown", last };
/^(3)$/ && do { $arch = "CGA", last };
$arch = "Whoopsie!" ; # DEFAULT
}
print "string: $arch\n";
| [EMAIL PROTECTED]
Sent by: [EMAIL PROTECTED] 02/09/2005 10:48 AM
|
To: [email protected] cc: Subject: Handling a uint16? |
Hi, list!
I know this is OT, but the Win32 list is ignoring my attempts to subscribe...
I'm working with Win32_VideoController, trying to get the VideoArchitecture method. Unfortunately, that's one of several methods that returns an unsigned integer (16 bit, in this case). Here's my question: How can I manipulate a uint16 (or a uint32, for that matter) so that it will work as the value in a "switch" statement? That is...
for ($obj->VideoArchitecture) {
/^(1)$/ && do { $arch = "Other", last };
/^(2)$/ && do { $arch = "Unknown", last };
/^(3)$/ && do { $arch = "CGA", last };
. . .
$arch = "Whoopsie!" ; # DEFAULT
}
When I try it, it doesn't even trip on the default! However, it does work in the clumsy if-elsif-elsif-...-else structure:
if ($obj->VideoArchitecture == 1) {
$arch = "Other";
} elsif ($obj->VideoArchitecture == 2) {
$arch = "Unknown";
} ...
I'd just prefer getting the more elegant code working (mostly 'cuz it's one of my favorite Perl thingies).
Thanks!
Deane_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
