Better HN
topnewbestaskshowjobs
Log inSign up

colonelguy

6 karma · joined Nov 10, 2015 (11y ago) · 2 submissions

Submissions

comment 11y ago · link · parent

Perl uses separate operators for mathematical addition and string concatenation.

  1 + 1 == 2;
  1 . 1 eq 11;
It uses separate operators for most mathematical and string operations, for that matter. There isn't much of a meaningful difference between strings and numbers in Perl -- it converts between then depending on the operation.

comment 11y ago · link · parent

You'd want to use the exists operator in that case. It checks if the hash key is present without auto vivifying it.

  my %hash = ();
  if (exists $hash{foo}) {print "This doesn't run!";}