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

  • SEARCH
  • Home
  • 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 7968427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:04:33+00:00 2026-06-04T07:04:33+00:00

I’m trying to understand how the eval statement works. Here’s a snippet of code

  • 0

I’m trying to understand how the eval statement works. Here’s a snippet of code I’m looking at that I don’t understand:

    eval `$SOME_DIR/util/dbget.pl \
          VARIABLE1 \
          VARIABLE2 \
          VARIABLE3 \
          VARIABLE4 `

Anyways my initial idea after some research is that eval just literally types in those strings in the command line, meaning it runs the .pl script, then… I’m not sure what it’s doing with those variables. The comment above this code said “get a few parameters” but I’m not sure what that means.

Does eval ‘VARIABLE’ initialize the variable? This seems to be the case because after the eval the code goes on to use these variables as if they’re now initialized (does if statement checks, etc).

I’m clearly new to this kind of scripting and just jumping into a large repository. Thanks for any help.

  • 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-06-04T07:04:34+00:00Added an answer on June 4, 2026 at 7:04 am

    Ok, the backticks are replaced with the output of the command between them.

    The eval takes that output and executes it as if typed.

    In this case I assume the perl is printing out some variable assignments, like set VARIABLE1=value1 or setenv VARIABLE1 value1. In which case, after the above eval, you should have $VARIABLE1 available to later csh code.

    Just running the .pl script (which I assume is Perl) without the eval would not affect the environment of the csh process. By using eval, you’re giving the Perl code permission to modify that environment.

    This means the Perl has to know that its output is intended for csh, btw. In sh/bash the syntax of variable assignment is different.

    ETA More attempted clarification:

    If you do this:

    $SOME_DIR/util/dbget.pl
    

    You get a bunch of variable assignment statements printed to your screen. This is not useful, and has no effect whatsoever on the actual variables in your shell.

    If you do this:

    echo `$SOME_DIR/util/dbget.pl`
    

    You get the same result in a more roundabout fashion: instead of the perl code printing directly to your screen, it’s printing into an expression that gets passed to the csh echo command, and then the echo is what does the actual printing to the screen. That distinction is subtle, but important: the backticks take control away from the perl and put it back in the hands of the shell. Once the shell has captured the output, it can store it in a variable, write it into a file, or do lots of other things with it that the Perl code doesn’t have to be rewritten to deal with. The Perl is still just printing.

    If you do this:

    eval `$SOME_DIR/util/dbget.pl`
    

    Then what the shell does is execute the output of the Perl as if it were typed at the prompt. This is very powerful. It’s also dangerous, because the surrounding program winds up executing code that the person who wrote that program has never seen. So you have to trust the source of that code (in this case the perl script) not to produce anything damaging (intentinonally or otherwise).

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

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.