Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: How to write macro in perl

by mihirjha (Novice)
on Jan 11, 2008 at 07:46 UTC ( #661829=note: print w/ replies, xml ) Need Help??


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

Hi Monks! Thanks for your questions. Please find the answers below. A macro to do what? -I want macro do following activity - To check whether the variable are define before using - Log the value passed to the variable entering/leaving a function i.e. to printing the trail of Input and output variable. - Memory statistic before entering and leaving the function to have idea about the memory status. I don't want that code to be part of the final product. I need those things for development/debugging purpose. What are your inputs? Input is .pl file What processing do you need to do? - To check whether the variable are define before using - Log the value passed to the variable entering/leaving a function i.e. to printing the trail of Input and output variable. - Memory statistic before entering and leaving the function to have idea about the memory status. What is your expected output? Expected output that all the above should be control with #ifdef , so that these things help in debugging but i don't want that to be part of the final product. What have you tried so far? I am trying to learn ExtUtils::PerlPP but i have not comprehand it properly. I hope, I have explained my situation. Please let me know , if you need more input from me. Regards, Mihir


Comment on Re^2: How to write macro in perl
Re^3: How to write macro in perl
by apl (Monsignor) on Jan 11, 2008 at 11:02 UTC
    It sounds like you want to learn Perl. I'd suggest you go to the O'Reilly web-site and look at their offerrings.
Re^3: How to write macro in perl
by McDarren (Abbot) on Jan 11, 2008 at 18:24 UTC
    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 :)

Re^3: How to write macro in perl
by TGI (Vicar) on Jan 11, 2008 at 18:34 UTC

    It looks to me like you are trying to do some profiling of your code as it runs in a test environment. Take a look at the Devel modules, you may be able to find a profiler that does what you want.

    If you want to inject code into subroutines for testing, you might find Hook::LexWrap useful.

    Update: I'd find it a lot easier to read your posts if you added some formatting to your nodes. When you have long lists of things, us an ordered or unordered list. Keep you paragraphs short. Whitespace helps improve readability.


    TGI says moo

Re^3: How to write macro in perl
by BrowserUk (Pope) on Jan 11, 2008 at 18:49 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2014-08-23 16:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (175 votes), past polls