Backtick::AutoChomp - auto-chomp() result of backtick(``) and qx//
Version 0.02
Automatically chomp() result of a backtick (``) or qx// command.
chomp()
$s = `echo blah` . 'stuff'; print $s; # blah\nstuff use Backtick::AutoChomp; $s = `echo blah` . 'stuff'; print $s; # blahstuff no Backtick::AutoChomp;
In bash, the shell will automatically chomp the result of a backtick call.
s=`whoami` # me echo =$s= # =me= echo =`whoami`= # =me=
In perl, we must** do:
$s = `whoami`; chomp($s); print "=$s=";
The goal of this module is for this to DWIM:
print "=".`whoami`."=";
Another case where this is potentially useful:
use Backtick::AutoChomp; printf "me(%s), host(%s), kernel(%s), date(%s)\n", `whoami`, `hostname`, `uname -r`, `date`, ;
** Yes, there are pure-perl ways to do whoami, hostname, etc. But keep in mind programs that don't have equivalents ... and also, especially for temp/quick-n-dirty scripts, the convenience factor :)
Note that this is implemented as a source filter. It replaces a backtick or qx statement with a do{} statement.
do{}
PPI, Filter::Simple
David Westbrook (CPAN: davidrw), <dwestbrook at gmail.com>
<dwestbrook at gmail.com>
Please report any bugs or feature requests to bug-backtick-chomp at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Backtick-AutoChomp. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-backtick-chomp at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Backtick::AutoChomp
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Backtick-AutoChomp
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Backtick-AutoChomp
CPAN Ratings
http://cpanratings.perl.org/d/Backtick-AutoChomp
Search CPAN
http://search.cpan.org/dist/Backtick-AutoChomp
Copyright 2008 David Westbrook, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Backtick::AutoChomp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Backtick::AutoChomp
CPAN shell
perl -MCPAN -e shell install Backtick::AutoChomp
For more information on module installation, please visit the detailed CPAN module installation guide.