Syntactic Confectionery Delight | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Yes, the -w switch is acceptable - there was in fact no warnings pragma before Perl 5.6, so it's a fairly recent thing. I still prefer -w for the time being as I never need to switch off warnings anywhere, anyway. (The warnings pragma allows for a more finegrained control if you do: you don't have to switch warnings off entirely anymore, you can selectively disable only specific ones.) The script is fine, "clean" wise, but could be written quite a lot more succintly. The only technical mistake is writing "$WH" etc where $WH (without the quotes) would do. If you're only using a single variable, you almost never want to put it in quotes. (There are a rare few cases, but you'll know those when you see them.) One thing I strongly urge you to, though, is to properly indent your code. It is barely acceptable in that short script, but would make a more complex one completely unreadable. Another note is that you're outputting a CGI header in your printGIF routine: if you go to the trouble of writing a function, then make it do exactly one thing. In this case, generate a GIF file. Nothing else. The header, in this case, is the main program's job. That way, you get functions you can reuse in other scripts later. For the same reason I would have the function return the GIF file, rather than printing it to STDOUT directly. Which brings up another point you might want to know about: the $|++; I dumped in there. See Suffering from Buffering about it. Here's how I'd write that: I would normally have used $width and $height instead of the shorter forms, but wanted to keep the hexdump aligned and somewhat compact. Makeshifts last the longest. In reply to Re: Strict, my and warnings
by Aristotle
|
|