Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How to write macro in perl

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


in reply to How to write macro in perl

A macro to do what?

What are your inputs?

What processing do you need to do?

What is your expected output?

What have you tried so far?

Please read How (Not) To Ask A Question and then update your question with enough detail to enable us to help you.

Replies are listed 'Best First'.
Re^2: How to write macro in perl
by mihirjha (Novice) on Jan 11, 2008 at 07:46 UTC
    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

      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

      It sounds like you want to learn Perl. I'd suggest you go to the O'Reilly web-site and look at their offerrings.
      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://661811]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-25 17:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found