perl $|=1; What is this?

perlvar is your friend. It documents all these cryptic special variables. $OUTPUT_AUTOFLUSH (aka $|): If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel. Default is 0 (regardless of whether the channel is really buffered by the system or not; $| tells you only … Read more

How do I find the module dependencies of my Perl script?

Check out Module::ScanDeps and the “scandeps.pl” utility that comes with it. It can do a static (and recursive) analysis of your code for dependencies as well as the %INC dump either after compiling or running the program. Please note that the static source scanning always errs on the side of including too many dependencies. (It … Read more

Perl – Subroutine redefined

Do you have a dependency loop? If Perl starts compiling your script and encounters a line like this: use PackageA; Perl pauses the compilation of your script; locates PackageA.pm and starts compiling it. If it encounters a line like this: use PackageB; Perl pauses the compilation of PackageA; locates PackageB.pm and starts compiling it. Normally, … Read more

How to run an anonymous function in Perl?

(sub { … }) will give you the pointer to the function so you must call by reference. (sub { print “Hello world\n” })->(); The other easy method, as pointed out by Blagovest Buyukliev would be to dereference the function pointer and call that using the { } operators &{ sub { print “Hello World” … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)