in reply to Re^2: How to write macro in perl
in thread How to write macro in perl

mihirjha,

I'm afraid that I'm still not clear about what it is that you are trying to do. You mention checking whether or not a variable is defined. Well, Perl has an inbuilt function for this, called defined. A very simple example of its usage is as follows:

#!/usr/bin/perl -l use strict; use warnings; my $foo = 1; my $bar; print '$foo is ', defined $foo ? "defined" : "not defined"; print '$bar is ', defined $bar ? "defined" : "not defined";
Which prints:
$foo is defined $bar is not defined

You also mention that you want to track the value of a variable. The easiest way to do this is with print, or perhaps something like Data::Dumper.

If, as apl suggests, you are new to Perl and want to learn, then I would suggest that a good place to start would be the Tutorials section of the Monastery.

In any case, welcome to PerlMonks.

Darren :)