tomazos has asked for the wisdom of the Perl Monks concerning the following question:

I want to take the literal source code of the parameter of a function call, and use it as a string at runtime. ( a similiar fashion to the # operator in the context of a macro definition in the C/C++ preprocessor.)

sub literalize { ???? } sub assert($) { my ($condition) = @_; my $literal_condition_code = literalize(@_); if ($condition) { print "assertion failed: $literal_condition_code\n"; } } assert(42 == 24);


assertion failed: 42 == 24

The C/C++ code would be:

#define assert(condition) { if (!condition) { printf("assertion failed +: %s\n", #condition); } }

Anyone know how to do something like this in Perl?