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 8379867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:18:17+00:00 2026-06-09T16:18:17+00:00

First timer…so let me know if there is anything that I have not paid

  • 0

First timer…so let me know if there is anything that I have not paid attention to whilst posing a question.

The question is how to use a scalar as a condition, as the code below does not work.

my @parameter=('hub');

my %condition;
$condition{'hub'}{'1'}='$degree>=5';

foreach (@parameter) {
       if ($condition{$_}{'1'}) {..}
}

I thought that is because the condition is not interpreted correctly, so I also tried the following, which also did not work.

if ("$condition{$parameter}{'1'}") { ..}

Would really appreciate 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-09T16:18:18+00:00Added an answer on June 9, 2026 at 4:18 pm

    You either want string eval, which evaluates a string as Perl code

    if (eval $condition{$_}{'1'}) { ...
    

    or perhaps a more secure approach would be using code references

    $condition{'hub'}{'1'} = sub { return $degree>=5 };
    
    if ($condition{$_}{'1'}->()) { ...
    

    In the second example, you are attaching a piece of code to a variable. The $var->() syntax executes the code and evaluates to the return value of the code.

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

Sidebar

Related Questions

I have a timer and I want to know if its efficient or not
First let me say that I really feel directionless on this question. I am
I gotta admit that's a first-timer bug for me. I've never seen that... I
I'm struggling with this Looper in Android. I have a timer that runs every
I have created a windows service which is currently having three timers. First timer
I have UINavigationController based app with two views. On the first view there is
I have a function that sets a timer, and calls itself back upon expiration
I have my timer being called from the viewDidLoad . For the first time
I've got a timer that I'm updating dynamically. ------------------update -------------------------- when I first posted
Say, I have the following C++ code. First I create a manual waitable timer

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.