in reply to PL/1's PUT DATA in Perl - is this possible?

You might like to look at Smart::Comments. With that, you place the variables of interest into a comment card and it gets traced.

The nice thing is that when your done debugging, you comment out the use Smart::Comments line and the trace output stops, but stays there for next time.

It is a source filter which are generally frowned upon, but as you disable it for production, the problems associated with source filters go away.

It's only downside (IMO) is that it's output is too verbose, producing multipe short lines for each trace line, but that can be fixed if it annoys you too.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^2: PL/1's PUT DATA in Perl - is this possible?
by Fletch (Bishop) on Nov 07, 2008 at 14:09 UTC

    You can also just use the comments and never even have a use Smart::Comments line in the file at all or worry about removing/commenting it out for production. Just run with a wrapper which calls perl appropriately when you want them turned on (zsh function; adjust accordingly for other inferior shells . . . :):

    scom () { local level="" if [[ $1 = (([#]##),#)## ]] then level="=$1" shift fi perl -MSmart::Comments${level} "$@" }

    By default it runs with the normal "###" level, but you can call it as scom '###,####,#####' foo.plx to enable more levels as necessary.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      Adjusted for inferior shell:

      #!/usr/bin/sh perl -e'$l=shift if $ARGV[0] =~ /#{3,}/; exec $^X, "-MSmart::Comments=$l", @ARGV; die $! '
      I use a bunch of aliases:
      alias smart='perl -MSmart::Comments' alias smart3='perl -MSmart::Comments="###"' alias smart34='perl -MSmart::Comments="###","####"' alias smart4='perl -MSmart::Comments="####"' ...