Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: How to write macro in perl

by mihirjha (Novice)
on Jan 11, 2008 at 07:46 UTC ( [id://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

Replies are listed 'Best First'.
Re^3: How to write macro in perl
by TGI (Parson) 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 (Patriarch) on Jan 11, 2008 at 18:49 UTC
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 :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-23 22:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found