Miscellaneous

 
   

Ruby Way
By Hal Fulton
Slots : 1.0
Table of Contents
 


Here are a few more miscellaneous notes:

  • See the IO, Dir, and File classes as well as the Kernel module for using the various input and output methods. There is no warn, and Ruby's format is not the same as Perl's format. The dbm-related functionality is in the DBM module. There is no equivalent to the vec function.

  • See the Process module for methods regarding processes and process groups. There is no alarm method.

  • See the socket module for low-level socket methods. See the Etc module for methods regarding user and group info. Use the Time class for time-related functions.

  • In Ruby, a variable set to nil is still considered defined. Perl's undef is used in various ways, but Ruby's undef is only useful for undefining methods and requires a parameter representing an already-defined method. See remove_method and undef_method as well. The closest equivalent to Perl assigning undef to a variable is Ruby assigning nil. Ruby's defined? is also different from Perl's defined because it checks for existence, not a nil value.

  • Ruby's dump method (see Marshal#dump) has nothing to do with Perl's dump function, which has no equivalent.

  • Ruby does not support form output. There are no formline, reset, scalar, and wantarray methods.

  • Ruby's eval is not used for exception handling as it is in Perl. It supports a second argument as the binding in which to evaluate the method. Ruby also supports class_eval and instance_eval.

  • Use raise (or fail) in place of die. Use begin/rescue/end in place of eval for catching exceptions. Use catch/throw for simple cases. There is no equivalent to the Carp module.

  • Ruby does not yet have a container equivalent to Perl's %SIG. Signal handlers are established via the trap method, but you are limited in accessing them later.

  • Commenting is done using the # symbol. Ruby also has a POD-like format called RD. It utilizes =begin/=end instead of =head/=cut.

  • You can use rdtool to extract and convert to HTML or man pages. However, there is no utility fully equivalent to perldoc.


   

 

 



The Ruby Way
The Ruby Way, Second Edition: Solutions and Techniques in Ruby Programming (2nd Edition)
ISBN: 0672328844
EAN: 2147483647
Year: 2000
Pages: 119
Authors: Hal Fulton

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net