Two Perl -> Ruby Questions

  1. What is the equivalent of Perl’s eval BLOCK form of eval? Per “man perlfunc”: “the code within the block is parsed only once…” Of course, I’m not exactly sure why an eval is being done in the code that I’m looking at, but seeing a Ruby equivalent may help.

  2. What is the equivalent of Perl’s pos SCALAR function? “Returns the offset of where the last m//g search left off for the variable in question… May be modified to change that offset. Such modification will also influence the \G zero-width assertion in regular expressions.”

TIA, as I am stuck on a conversion…

-a

···


austin ziegler
Sent from my Treo

Hi,

  1. What is the equivalent of Perl’s eval BLOCK form of eval? Per “man perlfunc”: “the code within the block is parsed only once…” Of course, I’m not exactly sure why an eval is being done in the code that I’m looking at, but seeing a Ruby equivalent may help.

eval BLOCK is used for exception handling, so that “begin … rescue … end”
should be the answer.

  1. What is the equivalent of Perl’s pos SCALAR function? “Returns the offset of where the last m//g search left off for the variable in question… May be modified to change that offset. Such modification will also influence the \G zero-width assertion in regular expressions.”

There’s no identical feature. Show me the original Perl code.

						matz.
···

In message “Two Perl → Ruby Questions” on 02/12/11, “Austin Ziegler” austin@halostatue.ca writes: