Sha256: 22f8e92edafbb373bc47922b2598ab66dba21ed72d09101d38d2b03a22d1b0fe

Contents?: true

Size: 647 Bytes

Versions: 4

Compression:

Stored size: 647 Bytes

Contents

require 'perl/interpreter'

class Object
  #
  # Evaluate Perl code.
  #
  # You can provide the code as a String:
  #
  #    Perl 'print STDERR "hello world\n"'
  #
  # An alternative is to pass a block, which will be evaluated in the context
  # of a Perl::Interpreter instance. This means all Perl::Interpreter methods
  # will be available, so you can write:
  #
  #   Perl do
  #     load 'test.pl'
  #     eval 'sub { ... }'
  #     run 'print "hi there!\n";'
  #   end
  #
  def Perl(args = nil, &block)
    @_perl ||= Perl::Interpreter.new

    if args
      @_perl.eval(args)
    else
      @_perl.instance_eval(&block)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-perl-04.01.2011.2 lib/perl/ext/object.rb
ruby-perl-04.01.2011.1 lib/perl/ext/object.rb
ruby-perl-04.01.2011 lib/perl/ext/object.rb
ruby-perl-0.99.15j lib/perl/ext/object.rb