Successfully reported this slideshow.

Ruby for perl developers

618 views

Published on

A short light talk about Ruby for Perl developers. It should be read "as-is" and taken lightly for .

Published in: Technology
  • And Perl also can be readable if you wish too, but you misunderstood the reason I chosen that syntax over the others...

    But it was great doing it even though you made a lot of nitpicking :P
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Some inaccuracies: Perl has a given/when for switches, and a 'foreach my $i ( 0 .. 99 )' is more Perlish than a C-style for loop, and several other small no-that-important discrepancies.

    It was a fun talk, thanks for doing it! :)
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Ruby for perl developers

  1. 1. Ruby For Perl Developers
  2. 2. What Is Ruby ? A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.
  3. 3. Ah, yes, but what is Ruby, and how it is different then Perl ?
  4. 4. puts 'bla' print “blan”
  5. 5. puts 'bla' 1.class print “blan” $a=1; print ref $a;
  6. 6. puts 'bla' 1.class nil.class = NilClass print “blan” $a=1; print ref $a; undef=undef
  7. 7. puts 'bla' 1.class nil.class = NilClass (0..999).each do { |i| … } print “blan” $a=1; print ref $a; undef=undef for (my $i =0; i<=999; i++) ...
  8. 8. $global = ... local = ... @instance_var = ... @@class_var = ... CONSTANT = ... ; Constant = ... our $global = ... local $local = ; my $local2 = ; - - -
  9. 9. Hash <= v1.8 a = { '22' => 'twenty two' } Hash ... a = { '22' => 'twenty two' }
  10. 10. Hash <= v1.8 a = { '22' => 'twenty two' } Hash >= 1.9 (v2.0 development) a = { '22' : 'twenty two' } Hash ... a = { '22' => 'twenty two' }
  11. 11. a = case b when /^d+$/ : 'digits' when /^w+$/ 'letters' when /^[a-fd]+$/, /^[A-Fd]+$/ 'hexa' when '1' : 'one' else b.class end use Switch; switch ($b) { case /^d+$/ { $a = 'digits'; } case /^w+$/ { $a = 'letters';} case /^[a-fd]+$/ { next; } case /^[A-Fd]+$/ { $a='hexa';} case ('1') { $a = 'one' } else { $a = ref $b; } }
  12. 12. Is that all ? Oh, no, we didn't even scratch the surface of Ruby.
  13. 13. Questions

×