Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: How to write macro in perl

by McDarren (Abbot)
on Jan 11, 2008 at 18:24 UTC ( [id://661943]=note: print w/replies, xml ) Need Help??


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 :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://661943]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-26 05:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found