in reply to Re^9: Use of uninitialized value in substr
in thread Use of uninitialized value in substr
In your mind, undef is some magical value. In mine, it's a function like any other.
Then my mind is right, and yours is wrong!
#! perl -slw use 5.010; use strict; use Inline C => Config => BUILD_NOISY => 1; use Inline C => <<'END_C', NAME => 'uCmp', CLEAN_AFTER_BUILD => 0; bool uCmp( SV* t ) { return (bool)( t == (&PL_sv_undef) ); } END_C print 'explicit undef: ', uCmp( undef ) ? 1 : 0; my $s; print 'uninitalised lexical: ', uCmp( $s ) ? 1 : 0; my @a; print 'uninitalised array element: ', uCmp( $a[ 5 ] ) ? 1 : 0; my %h; print 'uninitalised hash value: ', uCmp( $h{fred} ) ? 1 : 0; our $g; print 'uninitalised global: ', uCmp( $g ) ? 1 : 0; print 'Other unexplicit undef values: ', uCmp( `unknown_command` ) ? 1 + : 0; __END__ C:\test>uCmp explicit undef: 1 uninitalised lexical: 0 uninitalised array element: 0 uninitalised hash value: 0 uninitalised global: 0 'unknown_command' is not recognized as an internal or external command +, operable program or batch file. Usage: main::uCmp(t) at C:\test\uCmp.pl line 28.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^11: Use of uninitialized value in substr
by ikegami (Patriarch) on May 03, 2010 at 19:58 UTC | |
by BrowserUk (Patriarch) on May 03, 2010 at 20:07 UTC | |
by ikegami (Patriarch) on May 04, 2010 at 00:03 UTC | |
by JavaFan (Canon) on May 04, 2010 at 01:05 UTC | |
by BrowserUk (Patriarch) on May 04, 2010 at 00:49 UTC | |
by ikegami (Patriarch) on May 04, 2010 at 02:09 UTC | |
| |
by ikegami (Patriarch) on May 03, 2010 at 20:16 UTC | |
by BrowserUk (Patriarch) on May 03, 2010 at 20:19 UTC | |
by ikegami (Patriarch) on May 03, 2010 at 20:56 UTC |