perl5

How do Perl Cwd::cwd and Cwd::getcwd functions differ?

喜欢而已 提交于 2019-12-10 02:15:48
问题 The question What is the difference between Cwd::cwd and Cwd::getcwd in Perl, generally, without regard to any specific platform? Why does Perl have both? What is the intended use, which one should I use in which scenarios? (Example use cases will be appreciated.) Does it matter? (Assuming I don’t mix them.) Does choice of either one affect portability in any way? Which one is more commonly used in modules? Even if I interpret the manual is saying that except for corner cases cwd is `pwd` and

In Perl 5, how to queue a process/application after it reaches a maximum limit

大兔子大兔子 提交于 2019-12-06 15:32:20
I have a program that is being symlinked to multiple directories e.g. /main/foo.pl /run1/foo.pl -> /main/foo.pl /run2/foo.pl -> /main/foo.pl /run3/foo.pl -> /main/foo.pl /run4/foo.pl -> /main/foo.pl They're being run as cron jobs, hence I have the following entries in the crontab: */2 * * * * /run1/foo.pl */2 * * * * /run2/foo.pl */2 * * * * /run3/foo.pl */2 * * * * /run4/foo.pl A snippet of foo.pl is as below: use Fcntl qw(:flock); use autodie qw(:all); open my $self, '>', "$FindBin::Bin/lockme"; flock( $self, LOCK_EX|LOCK_NB ) or die "Cannot acquire lock, already running!"; { my $long_proc =

Can't use string (“1”) as a subroutine ref while “strict refs” in use

孤街醉人 提交于 2019-12-05 13:27:24
In a Perl daemon reacting to various events I'm trying to use a Null object pattern in 2 cases by creating anonymous subroutines, which should just return a value of 1 aka "true" (please scroll to the right to see the check subroutines for LOGIN and ALIVE events): package User; our %EVENTS = ( LOGIN => {handler => \&handleLogin, check => sub {1}, }, CHAT => {handler => \&handleChat, check => \&mayChat, }, JOIN => {handler => \&handleJoin, check => \&mayJoin, }, LEAVE => {handler => \&handleLeave, check => \&mayLeave, }, ALIVE => {handler => sub {}, check => sub {1}, }, BID => {handler => \

How do Perl Cwd::cwd and Cwd::getcwd functions differ?

旧街凉风 提交于 2019-12-05 01:15:40
The question What is the difference between Cwd::cwd and Cwd::getcwd in Perl, generally, without regard to any specific platform? Why does Perl have both? What is the intended use, which one should I use in which scenarios? (Example use cases will be appreciated.) Does it matter? (Assuming I don’t mix them.) Does choice of either one affect portability in any way? Which one is more commonly used in modules? Even if I interpret the manual is saying that except for corner cases cwd is `pwd` and getcwd just calls getcwd from unistd.h , what is the actual difference? This works only on POSIX

What is indirect object notation, why is it bad, and how does one avoid it?

拟墨画扇 提交于 2019-11-28 01:53:37
The title pretty much sums it up, but here's the long version anyway. After posting a small snippet of perl code, I was told to avoid indirect object notation, "as it has several side effects". The comment referenced this particular line: my $some_object = new Some::Module(FIELD => 'value'); As this is how I've always done it, in an effort to get with the times I therefore ask: What's so bad about it? (specifically) What are the potential (presumably negative) side effects? How should that line be rewritten? I was about to ask the commenter, but to me this is worthy of its own post. The main

Perl 5.20 and the fate of smart matching and given-when?

拥有回忆 提交于 2019-11-26 20:38:58
I just installed Perl 5.18, and I get a lot of warnings like this, given is experimental at .\[...].pl line [...]. when is experimental at .\[...].pl line [...]. Smartmatch is experimental at C:/strawberry/perl/site/lib/[...] line [...]. Looking into these warnings -- which I've never heard mentioned anywhere -- I was only able to find this in two places, perldelta for 5.18 , which only really mentions insofar as to say that the feature has been downgraded to experimental ? this nntp.perl.org post The Perl Delta still does the most to give mention as to what's happening with those features, it