[Chicago-talk] Two Perl curiosities
Alan Mead
amead2 at alanmead.org
Tue May 19 11:02:27 PDT 2015
I have two odd Perl things I've noticed recently. I'm using the stock
Centos 6.6 perl (v5.10.1 + whatever black magic Red Hat added).
Curiosity #1: I can't post the entire program code but I have a long script:
#!/usr/bin/perl
use strict;
use warnings;
[... about 150 lines omitted, including the beginning of a loop in a
subroutine]
my $a = $$pars{'alpha'};
my $delta = $$pars{'delta'};
my $taus = $$pars{'taus'};
print $fh join("\t", ($a, >>$b<<, 0, @$taus)), "\n" # >> <<
is my emphasis
I meant to type "delta" but I typed "b". Shouldn't Perl throw an error
because of the strict pragma or at least a warning? I get no warnings
when I "perl -c" and when running, all the warning I get is that $b is
uninitialized. When I create a small test script with this kind of
error, I get a warning: "Name "main::b" used only once: possible typo at
./test.pl line 11."
Curiosity #2: Also, I converted a program from Pascal to Perl and I
forgot one assignment operator (e.g., something like my $a := 1;) and
Perl never complained. What does := do in Perl? It's hard to google
ops. In a test program, it looks like it's a valid assignment operator?
$ cat test.pl
#!/usr/bin/perl
use strict;
use warnings;
my $a := 42;
print "$a\n";
$ ./test.pl
42
-Alan
--
Alan D. Mead, Ph.D.
President, Talent Algorithms Inc.
science + technology = better workers
+815.588.3846 (Office)
+267.334.4143 (Mobile)
http://www.alanmead.org
Announcing the Journal of Computerized Adaptive Testing (JCAT), a
peer-reviewed electronic journal designed to advance the science and
practice of computerized adaptive testing: http://www.iacat.org/jcat
More information about the Chicago-talk
mailing list