Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Yet another command line calculator' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Yet another command line calculator
Authored by: aaronrp on Feb 02, '05 11:41:35AM
Did we talk about Perl yet? Some tcsh aliases:

alias ? "perl -e 'print \!* , qq/\n/'"
alias ?? "perl -e 'print join ( qq/\n/, \!* ) , qq/\n/;'"
The second one allows you to print arrays -- useful for Perl's built-in arrays, like @INC (which contains the locations where Perl will look for modules). I used ? since it hearkens back to old BASIC days...

[ Reply to This | # ]
Yet another command line calculator
Authored by: kenahoo on Feb 02, '05 12:48:11PM

For that second one, you might be happier with:

alias ?? "perl -le 'print shift().q{,} while @ARGV>1; print for @ARGV"

because it won't get messed up by funny characters (quotes, perl operators, etc.) in the strings you're passing to it.

I did a few strange things there to avoid having to use more quotes and figure out how to escape them - the equivalent one-liner could be shortened to:

perl -le 'print map "$_,\n", @ARGV'

-Ken



[ Reply to This | # ]