Do you know where your variables are? | |
PerlMonks |
Re^2: Example 2: incrementing "something"by Mabooka-Mabooka (Sexton) |
on Apr 17, 2005 at 04:35 UTC ( [id://448578]=note: print w/replies, xml ) | Need Help?? |
Perl allows to use arithmetics on stringHere's the code:
Don't try it at homeWell, I recommend at the very least to redirect the output to a file:-).Why people do this?Again, the main reason: because it allows you. One may expect either a compile-time error or a run-time exception. But Perl allows you to shoot your own foot.Actually, this is an obfuscated (starting to love the word) code from a real-life app. The real application would send a query over the wire to the server, get a responce line -- -- that should look smth. like this: 200 OK 578 -- meaning " there're 578 lines yet to read from the socket, parse this line and create a loop: Well guess what? Once in 10000 times the server would get tired and send a garbled status line -- smth. like: and will start the almost infinite loop. (Try the code above). SolutionBe aware.use int($n). Ask your new hires during the inteview: "What is the result of the following operation: -?.
In Section
Tutorials
|
|