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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:10:24+00:00 2026-05-17T16:10:24+00:00

I am still a beginner with Perl, so please bear with me. This is

  • 0

I am still a beginner with Perl, so please bear with me. This is the situation I’m experiencing:

$var = "AB1234567";
$num = "1234567";
next if $var =~ /$num/;
print "Success!\n";

Now, my understanding is that it should print “Success!\n”, but in reality it doesn’t. However, if I change the regex to next if $var =~ /"$num"/;, this will actually print “Success!\n”.

However, if I change it to $var = "AB123456";, the original regex will work fine.

I understand that when enclosing strings using double quotations, it will dereference interpolate the variable. However, should it not be true in the case of regex? I’ve done regex using variables without quotations and it worked fine.

Thanks for your help!

EDIT:

I left out semi-colons in my example, but my original problem still stands.

EDIT:

I really should’ve just copied/pasted. I made a typo and used continue if instead of next if. Again, my problem still exists.

  • 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-17T16:10:24+00:00Added an answer on May 17, 2026 at 4:10 pm

    I think you are confused on what continue does. I’m not really sure of what you are trying to do here, but generally continue will break out of an if-block or go to the next iteration of a for-loop, while-loop, etc. When the pattern does match, continue is actually skipping over the print statement. When you change the value of $var, it no longer matches and the print statement is reached.

    Try this:

    $var = "AB1234567"
    $num = "1234567"
    print "Success!\n" if $var =~ /$num/;
    

    Randy

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

Sidebar

Related Questions

I am still a beginner but I want to write a character-recognition-program. This program
I'm still a beginner at .NET MVC, so please correct me if I'm doing
I'm still a beginner at regex so this is a little above me currently.
I'm still a beginner and I have been trying to solve this problem by
I'm still a beginner to Python, so I thought I could as well learn
I'm still a beginner in java. I dont have any idea on how to
i'm still a beginner, and guess it's a simple CakePHP question... all i want
I'm still a beginner with ruby and rails, and now I'm googling about methods
learning about loops (still a beginner) in VB.net. I have got the below code
I'm a (near complete) beginner, and this is my first foray into encryption -

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.