#!/usr/bin/perl -l use strict; use warnings; use Devel::Peek; sub display { my $text = shift; my $result = shift; my $ans = ($result) ? 'TRUE' : 'FALSE'; print STDERR "$text => CONDITIONAL WAS $ans"; Dump $result; print STDERR '-'x20, "\n"; } my @results; push @results, ['1==1', 1==1]; push @results, ['defined("x")', defined 'x']; push @results, ['defined("x")==1', defined('x')==1]; push @results, ['defined("x")eq"1"', defined('x')eq"1"]; push @results, ['1==0', 1==0]; push @results, ['defined(undef)', defined undef]; push @results, ['!defined(undef)', !defined undef]; push @results, ['defined(undef)==0', defined(undef)==0]; push @results, ['defined(undef)eq""', defined(undef)eq""]; display(@$_) for ( @results ); __END__ 1==1 => CONDITIONAL WAS TRUE SV = PVNV(0x5de5c8) at 0x479ab8 REFCNT = 1 FLAGS = (IOK,NOK,POK,pIOK,pNOK,pPOK) IV = 1 NV = 1 PV = 0x47c3e8 "1"\0 CUR = 1 LEN = 10 -------------------- defined("x") => CONDITIONAL WAS TRUE SV = PVNV(0x5de5c8) at 0x479ab8 REFCNT = 1 FLAGS = (IOK,NOK,POK,pIOK,pNOK,pPOK) IV = 1 NV = 1 PV = 0x47c3e8 "1"\0 CUR = 1 LEN = 10 -------------------- defined("x")==1 => CONDITIONAL WAS TRUE SV = PVNV(0x5de5c8) at 0x479ab8 REFCNT = 1 FLAGS = (IOK,NOK,POK,pIOK,pNOK,pPOK) IV = 1 NV = 1 PV = 0x47c3e8 "1"\0 CUR = 1 LEN = 10 -------------------- defined("x")eq"1" => CONDITIONAL WAS TRUE SV = PVNV(0x5de5c8) at 0x479ab8 REFCNT = 1 FLAGS = (IOK,NOK,POK,pIOK,pNOK,pPOK) IV = 1 NV = 1 PV = 0x47c3e8 "1"\0 CUR = 1 LEN = 10 -------------------- 1==0 => CONDITIONAL WAS FALSE SV = PVNV(0x5de5c8) at 0x479ab8 REFCNT = 1 FLAGS = (IOK,NOK,POK,pIOK,pNOK,pPOK) IV = 0 NV = 0 PV = 0x47c3e8 ""\0 CUR = 0 LEN = 10 -------------------- defined(undef) => CONDITIONAL WAS FALSE SV = PVNV(0x5de5c8) at 0x479ab8 REFCNT = 1 FLAGS = (IOK,NOK,POK,pIOK,pNOK,pPOK) IV = 0 NV = 0 PV = 0x47c3e8 ""\0 CUR = 0 LEN = 10 -------------------- !defined(undef) => CONDITIONAL WAS TRUE SV = PVNV(0x5de5c8) at 0x479ab8 REFCNT = 1 FLAGS = (IOK,NOK,POK,pIOK,pNOK,pPOK) IV = 1 NV = 1 PV = 0x47c3e8 "1"\0 CUR = 1 LEN = 10 -------------------- defined(undef)==0 => CONDITIONAL WAS TRUE SV = PVNV(0x5de5c8) at 0x479ab8 REFCNT = 1 FLAGS = (IOK,NOK,POK,pIOK,pNOK,pPOK) IV = 1 NV = 1 PV = 0x47c3e8 "1"\0 CUR = 1 LEN = 10 -------------------- defined(undef)eq"" => CONDITIONAL WAS TRUE SV = PVNV(0x5de5c8) at 0x479ab8 REFCNT = 1 FLAGS = (IOK,NOK,POK,pIOK,pNOK,pPOK) IV = 1 NV = 1 PV = 0x47c3e8 "1"\0 CUR = 1 LEN = 10 --------------------