develooper Front page | perl.perl5.porters | Postings from July 2018

Antw: Re: [perl #133391] Bad "Use of uninitialized value within@socks in ref-to-glob cast"

Thread Previous
From:
Ulrich Windl
Date:
July 18, 2018 12:02
Subject:
Antw: Re: [perl #133391] Bad "Use of uninitialized value within@socks in ref-to-glob cast"
Message ID:
7739_1531915321_5B4F2C39_7739_14_1_5B4F2C2D020000A10002C68F@gwsmtp1.uni-regensburg.de
>>> "Tom Molesworth via RT" <perlbug-followup@perl.org> schrieb am 18.07.2018 um
12:43 in Nachricht <rt-4.0.24-30574-1531910616-886.133391-94-0@perl.org>:
> You have a 1-in-10 random condition within the first 'unless' clause, so
> $socks[$i] is not guaranteed to be defined.

You mean I was hit by "DeMorgan"?

unless ($socks[$i] || int(rand(10)) == 0) {

was meant to be

"if (!$socks[$i] || int(rand(10)) == 0) {"

The problem was that I started with "unless ($socks[$i])" and added the "|| int(rand(10)" without applying negation...

With the logic fix, the output looks much better now:
---
./tester.pl
sock 4
new sock 4
msg YYYYYYYYYYYYYYYYYYYYY
sock 7
new sock 7
msg XXXXXXXXXXXXXXXXXXXX
sock 8
new sock 8
msg 777777777
sock 6
new sock 6
msg OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
sock 0
new sock 0
msg 7777777777777777777
sock 7
msg 1111111111111111111111111111111111111111111111111
sock 2
new sock 2
msg TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
sock 5
new sock 5
msg FFFFFFF
sock 7
close sock 7
new sock 7
msg OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
sock 9
new sock 9
msg MMM
sock 7
msg M
sock 7
msg BBBBBBBBBBBBBBBBBBBBBBB
sock 7
msg TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
sock 6
msg 444444444444444444444444
sock 8
msg WWWWWWWWWWWWWWWW
sock 8
msg AAAAA
sock 2
msg ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
sock 1
new sock 1
msg DDDDDDDDDDDDDDDDDDD
sock 8
msg LLLLLLLLLLLLLLLLLLLLLLLLLLLL
sock 7
msg JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
^Z
[2]+  Stopped                 ./tester.pl
windl@rksapv04:~/src/C/isredir-udp> fg
./tester.pl
sock 1
msg 111111111111111111
^C
windl@rksapv04:~/src/C/isredir-udp> fg
emacs

[1]+  Stopped                 emacs
windl@rksapv04:~/src/C/isredir-udp> ./tester.pl
sock 7
new sock 7
msg 0000000000000000000000000000
sock 5
new sock 5
msg YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
sock 0
new sock 0
msg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
sock 8
new sock 8
msg NNNNNNNNNNNNNNNNNNNNNNNN
sock 7
msg SSSSSSSSSSS
sock 7
close sock 7
new sock 7
msg UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
sock 6
new sock 6
msg 5555555555555555555
sock 0
msg UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
sock 9
new sock 9
msg QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
sock 6
msg OOO
sock 1
new sock 1
msg LLL
sock 8
msg VVVVVVVVVVVVV
sock 4
new sock 4
msg CCCCCCCCCCCCC
sock 4
msg QQQQQQQQQQQQQQQQQQQQQQQQQQQQ
sock 9
msg YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
sock 7
msg
send():
sock 8
msg EEEEEEEEEEEEEEEEEEEEEEEEEEEEE
sock 2
new sock 2
msg
send():
sock 2
msg XXXXXXX
sock 5
msg
send():
sock 4
msg NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
sock 3
new sock 3
msg JJJJJJJJJJJJJJJJJJJJJJJJJ
^C
---

Regards,
Ulrich

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About