| |||||||||||
| |||||||||||
Flocking Posted by TedH (TedH), 21 April 2008 Hi guys:Just a question really. In the code below (not mine - I'm learning about handling flock differently), I notice the use of a semi-colon for a write, but not in the other cases. The code works fine, just wondering why the difference? Code:
Cheers - Ted Posted by KevinAD (KevinAD), 21 April 2008 The semi-colon has nothing to do with the use of flock or anything else for that matter. The last line (or in this case the only line) of a block of code: {}, does not need a semi-colon, it's optional. In my opinion, for consitancy sake you should always put one. Posted by KevinAD (KevinAD), 21 April 2008 Hard core perl coders will tell you to use the Fcntl module and import the flock constants into your program. I am a bit ambivalent on this issue but I tend to use Fcntl too and import the symbolic names, in some cases it might be necessary although I am not sure about that, maybe Graham knows. See the flock() function and the Fcntl module for more details.Posted by TedH (TedH), 21 April 2008 Hi Kevin, Thanks. I usually just do a Code:
Then remove the comment when I put it on my live Unix server. My local testbed is Indigo perl on a Windows PC, so it's commented out there. Which is okay if there's just one, But - when there are hundreds or thousands of lines of code, with a bunch of flocks in, I figured I need a more efficient way to do it - hence the variable option. I'll use the semi-colon as suggested. Cheers - Ted Posted by KevinAD (KevinAD), 22 April 2008 It was evident what you were doing by this line:# Variable $flock = "0"; # Set to to 1 for Unix Been there, done that, too. You can make that dynamic: my $flock = ($^O =~ /MSwin32/i) ? 1 : 0; Then you don't have to comment it out and it will work on Windows and Unix/Linux. Posted by TedH (TedH), 22 April 2008 That's neat ![]() This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |