Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 500645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:06:32+00:00 2026-05-13T06:06:32+00:00

while line = gets next if line =~ /^\s*#/ # skip comments break if

  • 0
while line = gets
   next if line =~ /^\s*#/    # skip comments
   break if line =~ /^END/   # stop at end

   #substitute stuff in backticks and try again
   redo if line.gsub!(/`(.*?)`/) { eval($1) } 

end

What I don’t understand is this line:

line.gsub!(/`(.*?)`/) { eval($1) }
  1. What does the gsub! exactly do?
  2. the meaning of regex (.*?)
  3. the meaning of the block {eval($1)}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:06:32+00:00Added an answer on May 13, 2026 at 6:06 am
    1. It will substitute within the matched part of line, the result of the block.
    2. It will match 0 or more of the previous subexpression (which was ‘.’, match any one char). The ? modifies the .* RE so that it matches no more than is necessary to continue matching subsequent RE elements. This is called “non-greedy”. Without the ?, the .* might also match the second backtick, depending on the rest of the line, and then the expression as a whole might fail.
    3. The block returns the result of eval (“evaluate a Ruby expression”) on the backreference, which is the part of the string between the back tick characters. This is specified by $1, which refers to the first paren-enclosed section (“backreference”) of the RE.

    In the big picture, the result of all this is that lines containing backtick-bracketed expressions have the part within the backticks (and the backticks) replaced with the result value of executing the contained Ruby expression. And since the outer block is subject to a redo, the loop will immediately repeat without rerunning the while condition. This means that the resulting expression is also subject to a backtick evaluation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Boolean/logical operators in C are required to yield either 0… May 16, 2026 at 6:04 pm
  • Editorial Team
    Editorial Team added an answer That's the correct method. Calling openConnection() doesn't actually do anything.… May 16, 2026 at 6:04 pm
  • Editorial Team
    Editorial Team added an answer It's not really about the LINQ query, but rather that… May 16, 2026 at 6:04 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

pipe = IO.popen(my_cmd 2>&0) while ??? line = pipe.gets puts line if some_condition end
I am trying to understand this code snippet: while row = input.gets row.strip! next
Whenever I write a program in eclipse each line gets complied as go to
I'm running a while loop reading each line in a file, and then fork
The Challenge Reach the end of the level! Bonus points if you hit each
var buffer = new byte[short.MaxValue]; var splitString = new string[] {\r\n}; while (_tcpClient.Connected) {
I've got a class library doing all my NHibernate stuff. It also handles all
A slow multiple precision implementation of a mandelbrot generator. Threaded, using POSIX threads. Gtk
I have these lines in my ~/.inputrc : set editing-mode vi set keymap vi
I have a bash script that I mostly use in interactive mode. However, sometimes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.