undef Questions

5

Solved

I have a fragment in this form: my $a = $some_href->{$code}{'A'}; # a number or undef my $b = $some_href->{$code}{'B'}; # a number or undef $a = 0 unless defined($a); $b = 0 unless defined($...
Stutter asked 29/8, 2009 at 10:37

1

This code dies as I expect it to: use strict; use warnings; open my $fh, "<", "" or die $!; But this does not: use strict; use warnings; open my $fh, "<", undef or die $!; What is goi...
Eleazar asked 20/4, 2017 at 14:2

1

Solved

Please take a look at the following code: use strict; use warnings; print "subroutine is defined\n" if defined &myf; myf(); sub myf { print "called myf\n"; } undef &myf; #myf(); print...
Marlenamarlene asked 20/9, 2016 at 10:52

2

Solved

SHORT QUESTION What are the best ways to represent true and false consistently in libraries of Perl code? 1 / 0? 1 / the special empty string that Perl's native boolean operators return? undef? ...
Formwork asked 17/9, 2016 at 0:46

1

Solved

LLVM introduces the concept of "poison value", which I never feel sure to understand. For example, for the statement %add = add nsw i32 %x, 1 If %x+1 is strictly larger than the largest i32 int...
Roentgenology asked 9/12, 2015 at 23:28

1

Solved

Under use strict; use warnings; my $foo = undef; the expressions $foo . '' and "$foo" both produce Use of uninitialized value $foo in ... at ... but the following expression gives the e...
Pride asked 9/10, 2012 at 13:45

1

Solved

While reading from a configuration file in Perl there might be cases when a line is invalid and it does not need to get added to my array of valid lines. Since I'm using a for loop here, even the i...
Oliy asked 20/6, 2012 at 15:31

1

Solved

How do I remove a tcl procedure? One can unset a variable, override an alias with interp alias {} myproc {} otherproc, override a proc with one defined inside another namespace with namespace i...
Natter asked 27/3, 2012 at 11:2

3

Solved

In many of the C and C++ files I have seen macros like this: #ifdef X #undef X // no statements in between #endif I feel that, it's adequate to simply write: #undef X If the macro X wasn't de...
Continence asked 1/2, 2012 at 3:56

3

Solved

Task: to build hash using map, where keys are the elements of the given array @a, and values are the first elements of the list returned by some function f($element_of_a): my @a = (1, 2, 3); my %h...
Assimilable asked 20/1, 2012 at 18:4

6

Solved

How do you get Perl to stop and give a stack trace when you reference an undef value, rather than merely warning? It seems that use strict; isn't sufficient for this purpose.
Waynant asked 16/9, 2008 at 22:30

3

Solved

I currently have a couple of #define in c files that turn off some functionality to hardware for testing. However, I want to document them with doxygen when they are undefined as well. For example...
Hintz asked 24/8, 2010 at 17:2

3

I need to hide warnings within eval but the rest of the code should continue to throw warning messages. Here is what I have - eval "\$value = $hash->{key}"; now value of $hash->{key} could be...
Guardian asked 25/1, 2011 at 20:51

9

Solved

I'm working in C++ and I need to know if a scalar value (for instance a double) is "defined" or not. I also need to be able to "undef" it if needed: class Foo { public: double get_bar(); private...
Bawl asked 23/1, 2009 at 15:11
1

© 2022 - 2024 — McMap. All rights reserved.