Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Contribute a hack to the new "Perl Hacks" book

by hossman (Prior)
on Dec 17, 2005 at 01:21 UTC ( [id://517417]=note: print w/replies, xml ) Need Help??


in reply to Contribute a hack to the new "Perl Hacks" book

I don't really want to subscribe the this list, but I have this little ditty in my .emacs file, and i use it at least once a day...

;; http://perlmonks.org/index.pl?node_id=188959 ; run perl on the current region, updating the region (defun perl-replace-region (start end) "Apply perl command to region" (interactive "r") (shell-command-on-region start end (read-from-minibuffer "Replace region comma +nd: " '("perl -ple \'$_=eval\'" . 12 )) t t ) (exchange-point-and-mark) )

I got it from this snippet but added the eval so that i can immediately evaluate simple expressions (usually math equations). Since it's interactive (and since the cursor is placed in just the right spot) it's easy to replace the eval with something else when I need to.

(Anyone who wants to mail this in should feel free)

Log In?
Username:
Password:

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

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

    No recent polls found