Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Actually, it reacts to commands that start with - or '-. The reason I use -- is because I normally use it with SQL Server to generate scripts. The reason for the '- is because I also use VB (yes, boo hiss =/). I work in a Microsoft-only shop and I find that the languages I need to use benefit greatly from code generation.

The reason for B::Deparse is so the script can get the source for the anonymous subs that have been generated. If you wish to see the entire subroutine that is generated for a macro, use the fullcodefor macro. codefor reconstructs the macro as you gave it, although it does a bit of cleaning up which I like.

As for another example, here's a simple note/recall pair of macros.

-- def_macro note my $file = shift or die "Please indicate the note you wish to create/a +ppend to"; mkdir 'notes' unless -e 'notes'; open my $fh, ">>", "notes/$file" or die "Couldn't open note for write: + $!"; local $/; print $fh $_ while <>; close $fh or die "Trouble closing file: $!"; print "Successfully appended to note $file";

-- def_macro recall my $file = shift or die "Please indicate the note you wish to open"; die "Note $file does not exist" unless -f "notes/$file"; open my $fh, "<", "notes/$file" or die "Couldn't open note for read: $ +!"; local ($/,$\); print <$fh>; close $fh or die "Couldn't close file: $!";

To use:

-- note example This should be the first line
-- note example This should be the second line
-- recall example

Produces:

This should be the first line This should be the second line


In reply to Re^2: clipcommand.pl (Embed perl into your clipboard) by antirice
in thread clipcommand.pl (Embed perl into your clipboard) by antirice

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (10)
    As of 2015-07-28 21:29 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (259 votes), past polls