On Mon, March 7, 2005 10:15 pm, John Carter said:
> Perl has justly been called the "Swiss Army Chain Saw" of Unix System
> Administration.
>
> Much of this reputation has centered on the amazing things you can do
> in just one line of code from the command line.
>
> Ruby's more readable and cleaner syntax can, on occasions, get in the way,
> make our one liners a few characters longer, and on other occasions
> Rubies objects all the way down power makes our one liners several
> characters shorter.

I'd rather not, thanks. It takes about one minute to start up vi and save
the file afterwards. You can also use it again tomorrow.

This was interesting to me, though: "Can we command line option an idiom?".
Can we, instead, idiom the CLI?

> Challenge for the Day :-
>    Think Laterally on how to tweak Ruby to be better at One Liners.
>
> Please put your responses under the following
> "Hats"...(http://www.mycoted.com/creativity/techniques/sixhats.php)
>
> (Tip: Save your "It (won't work / we don't need)" notions for the Black
> Hat slot)
>
> White Hat - Objective Thinking - What techniques and resources do we
> already have in Ruby for One Liners?
> ====================================
>
> Command Line options
> -e 'Some ruby'
> -n 'Iterate over stdin'
> -i.bak Backup file
> -l Chomp!
> -rmodule
> -p print each line
> -a autosplint
> -Fpattern
> -Orecord seperator
>
> Idioms
> ruby -nple 'gsub(regex,replacement)'
> ruby -i.bak -nple 'expr' files.*
> ruby -nle 'puts "stuff #{expr involving $1,$2,...}" if /blah(bloo)/'
> Histogram...
> ruby -nle 'BEGIN{$a=Hash.new(0)};$a[$1]+=1 if
> /(PATTERN)/;END{$a.each_pair{|k,n| puts "#{n}\t#{k}"}}'
>
> Modules
> eg. -rcsv does juicy things.
>
> Your standard techniques and Idioms here please...
>
> Red Hat Thinking - Emotions
> ===========================
>
> eg. The BEGIN/END stuff and the -a stuff always feels slightly clunky to
> me.
>
> Your emotions here.
>
> Yellow Hat thinking - Glowingly positive.
> ========================================
>
> Think of what could be if magic happens. List the wild "Wouldn't it be
> nice..."
>
> eg. Wouldn't it be nice if rexml had some oneliner specific shortcuts?
>
>
> Green Hat thinking - Creative hunt for alternatives, provocations, changes
> =================================================================
>
> What new options could we introduce. eg. -B and a -E option that
> work like -e, but instead of the clunky BEGIN, END blocks.
>
> What modules to -r? Perhaps -n should implicitly -r some modules?
>
> Can we command line option an idiom?
>
> Can we modularize an Idiom?
>
> Can we...? Your wild questions and Ideas here.
>
> Black Hat thinking:
> ==================
> The hat of judgment and caution.
>
>
> Blue Hat Thinking:
> =================
>
> This email is starting a process, how can we deploy the results? eg.
> RubyGarden Wiki, rubyforge "Code Snuppets", fold into Ruby CVS mainline,
> ... Your ideas here.
>
> John Carter

E