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

[MacPerl] vec() & unpack() 5.0.6r1m



PowerMac 7100/66 System 7.5.1
Macperl v5.0.6r1m

Why does the following script only produce the expected results the first time
the script is run?

for ($i = 0;$i < 5;$i++) {
    vec($vector, $i, 1) = 1;
    print $i, '. Setbits are: ', unpack("%32b*", $vector), "\n";
}
print '$vector is: "', $vector, '" or ', unpack("b*", $vector), "\n";

Expected results and the actual results of the first run
--------------------------------------------------------
0. Setbits are: 1
1. Setbits are: 2
2. Setbits are: 3
3. Setbits are: 4
4. Setbits are: 5
$vector is: "#031#" or 11111000

Results of subsequent runs without quitting and relaunching MacPerl
-------------------------------------------------------------------
0. Setbits are: 0
1. Setbits are: 48
2. Setbits are: 112
3. Setbits are: 0
4. Setbits are: 5
$vector is: "#031#" or 11111000

A work around for this problem is to quit and relaunch MacPerl after running
a script that uses vec() and unpack(). Can I be sure that the results will
really be correct the first time the script is run?

Has anyone else noticed this and thought it was a problem?

--PGD