David Alan Black wrote:
>
> > $ perl -e 'while (<>) { if (/^\d/) { print "Starts with digit\n" } else
> > { print "Nope\n" } }'
> 
> You could do:
> 
> $ ruby -we 'while gets; puts(/^\d/ && "Starts with digit" || "Nope"); end'
> 
> or if you want to give your fingers more exercise (and see a couple of
> other little Ruby things in action):
> 
> $ ruby -we 'while gets; puts begin if /^\d/ then "Starts with digit" \
>             else "Nope" end end end'
> 

Using the -n (or -p) option, you can ommit the while-loop:

  $ ruby -ne 'puts /^\d/ ? "Starts with digit" : "Nope"'

With -p option (prints out $_ in each iteration):

  $ ruby -pe '$_ = /^\d/ ? "Starts with digit" : "Nope"'


Regards,

  Michael

-- 
Michael Neumann
merlin.zwo InfoDesign GmbH
http://www.merlin-zwo.de