Why does !1 give me nothing in Perl?

Be careful: what you’ve written isn’t doing what you think it’s doing. Remember, perl has no real boolean datatype. It’s got scalars, hashes, lists, and references. The way it handles true/false values, then, is contextual. Everything evaluates to “true” in perl except for undefined variables, the empty list, the empty string, and the number 0. … Read more

Demystifying the Perl glob (*)

Assignment to a glob *glob = VALUE contains some magic that depends on the type of VALUE (i.e., return value of, say, Scalar::Util::reftype(VALUE)). If VALUE is a reference to a scalar, array, hash, or subroutine, then only that entry in the symbol table will be overwritten. This idiom local *array = shift(); #use @array here … Read more

How to read to and write from a pipe in Perl?

You can use IPC::Open3 to achieve bi-directional communication with child. use strict; use IPC::Open3; my $pid = open3(\*CHLD_IN, \*CHLD_OUT, \*CHLD_ERR, ‘cat’) or die “open3() failed $!”; my $r; for(my $i=1;$i<10;$i++) { print CHLD_IN “$i\n”; $r = <CHLD_OUT>; print “Got $r from child\n”; }

Perl DBD::Oracle Module installation

Install if missing ExtUtils-MakeMaker module (sudo yum install perl-ExtUtils-MakeMaker) Install Perl DBI module ($ yum install perl-DBI) Manually install below three RPMs for Oracle instant client (from Instant Client Downloads for Linux x86-64. The example is for v11.2.0.3.0-1: adapt the commands below to the actual version.) oracle-instantclient11.2-basic-11.2.0.3.0-1 oracle-instantclient11.2-devel-11.2.0.3.0-1 oracle-instantclient11.2-sqlplus-11.2.0.3.0-1 I am using 64 bit Linux … Read more