Questions tagged [undef]

EXAMPLES:

undef $foo;
my $bar = undef;

SEE ALSO:
perldoc -f undef

57 questions
4
votes
3 answers

Is there a built-in function to clear all variable values

I'm looking for a way to clear all of my arrays in a Perl program. Currently, I'm calling a subroutine that explicitly "resets" all arrays: sub clear_arrays{(@array1,@array2,@array3)=((),(),());} This forces me to find all the arrays in the program…
CheeseConQueso
  • 5,831
  • 29
  • 93
  • 126
4
votes
3 answers

How can I render undefined values from printf in Perl?

I'm looking for an elegant way to denote undefined values in situations where formatted numbers usually render. I'll work up a small example. For starters, you of course can't use this: #!/usr/bin/perl use strict; use warnings; for my $s (1, 1.2,…
Cary Millsap
  • 806
  • 6
  • 17
4
votes
2 answers

practical use for undef

Possible Duplicate: undef - Why would you want to undefine a method in ruby? Can anyone lay out a practical use for undef in ruby? I'm coming from languages like javascript and python that don't have it built in. You could of course simulate it…
chalmers
  • 125
  • 2
  • 6
4
votes
1 answer

multiple regex using perl

Hi this website already helped me a few times fixing my problems in perl. this is the first time i have to ask a question because i can't find an answer neither on google nor on stack overflow. What i am trying to do is to get the content between…
Lehmann
  • 41
  • 2
4
votes
1 answer

Erlang application undef error (exited: {bad_return,)

I am trying to run a custom application but get multiple errors. I believe the main egs app gets an error because it calls the egs patch app which has an undefined type. I cant figure out how to get this working I have tried recompiling the code…
mattk
  • 333
  • 3
  • 11
3
votes
2 answers

Macro definition not replaced as expected?

I followed the online tutorial and wanted to use #undef to design my debug output function. I wrote a debugOut.h file. The content is as follows: #include #define NOOP //(void(0)) #undef DEBUG_PRINT #if DEBUG_OUT #define DEBUG_PRINT…
Gerrie
  • 736
  • 3
  • 18
3
votes
4 answers

How can I print a literal 'null' for undefined values in Perl?

I am running a query 'describe table' and it returns value of 'null' for the 'default' column. However, when I try to print the value from database to an HTML table it is not printing 'null'. It is just always blank. This is how I am storing the…
Omnipresent
  • 29,434
  • 47
  • 142
  • 186
3
votes
3 answers

Good way to document #undef in doxygen

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: This works fine: /// \def…
Dennis Miller
  • 952
  • 1
  • 9
  • 22
3
votes
3 answers

Initialising with "undef" for self-documenting code?

Sometimes I'd like to write: my $var = shift // undef; # argument is optional # or my $var = $val{optional_value} // undef; to indicate that it is ok to have the argument missing, otherwise // undef is useless, of…
Sadko
  • 166
  • 9
2
votes
4 answers

Why is 'undef' not detected by this Perl fragment?

I would expect the block in the second 'if' statement to be entered because of the undef value but the logs show that it isn't being entered. sub getcmd{ my $self = $_[0]; if ( $self->_recv == OK ){ push @{$self->{'log'}}, ['NOTICE',…
Rob Wells
  • 36,220
  • 13
  • 81
  • 146
2
votes
3 answers

undefine and redefine the __cplusplus macro

I want to undefine and redefine the __cplusplus macro am getting however compilation error:__cplusplus was not declared in this scope #define TEMP_VERSION __cplusplus // temporary macro to hold the __cplusplus containt #undef __cplusplus #define…
Mouin
  • 1,025
  • 4
  • 19
  • 33
2
votes
1 answer

Why does defined function not work?

I have a piece of code which does not work as I expect it to work. MAinly the defined function does not work. @jobs = qw[job1 undef job2]; if(defined($jobs[1])) { print "Job 1 is defined"; } I get the output Job 1 is defined clearly $jobs[1] is…
user582452
  • 23
  • 2
2
votes
3 answers

I am a bit lost as to the meaning of this C preprocessor statement,

So, to start off, here's the code, with actual names switched for generic ones to limit confusion. /* Get the list of Hotkey commands */ #define A_COMMANDS_MACRO(a, b, c, d) a = b , enum { #include "commandsFile.def" } ; #undef …
Ken Bellows
  • 6,711
  • 13
  • 50
  • 78
2
votes
1 answer

Assigning multiple values in perl, trouble with undef

I want to return several values from a perl subroutine and assign them in bulk. This works some of the time, but not when one of the values is undef: sub return_many { my $val = 'hmm'; my $otherval = 'zap'; #$otherval = undef; my…
Tobu
  • 24,771
  • 4
  • 91
  • 98
2
votes
2 answers

What is the value if you shift beyond the last element of an array?

In this piece of code, shift is used twice, even though the method only takes one parameter: sub regexVerify ($) { my $re = shift; return sub { local $_ = shift; m/$re/ ? $_ : undef; }; } What does this make the value of…
CptSupermrkt
  • 6,844
  • 12
  • 56
  • 87