in reply to Re: Comparing undefined values
in thread Comparing undefined values
Great mind, great minds ... ;)
Here's the test program I wrote:
#!/usr/bin/perl -l use strict; use warnings; use Math::Combinatorics; my %v = ( undef => undef, empty => '', zero => 0, name => 'Ovid', ); my $combine = Math::Combinatorics->new( count => 2, data => [ keys %v ], ); while ( my ( $x, $y ) = $combine->next_combination ) { compare( $x, $y ); } foreach my $x ( keys %v ) { compare( $x, $x ); } sub compare { my ( $x, $y ) = @_; my ($X, $Y) = ($v{$x}, $v{$y}); print "\nComparing '$x' and '$y'"; no warnings 'uninitialized'; print +( ( defined $X == defined $Y ) && $X eq $Y ) ? "yes" : "no"; }
Cheers,
Ovid
New address of my CGI Course.
|
|---|