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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:33:12+00:00 2026-06-17T12:33:12+00:00

I am facing problems with Perl string matching/searching using both index as well as

  • 0

I am facing problems with Perl string matching/searching using both index as well as the =~ operator. I need to search for the string “RT @zaynmalik: Big cover for @cosmopolitanuk ! Boys looking slick http://example.com/FcWA80HI” in a text file.

if($splitlines[1] =~ /RT @zaynmalik: Big cover for @cosmopolitanuk ! Boys looking slick http://example.com/FcWA80HI/){
     ## Do something ##
}

However, because ‘@‘ is a special character in Perl, I am getting compile errors. Could you suggest me a method to do this? I tried saving the string to a variable like $str, but it did not work (which is understandable).

So, this is what I am doing now,

$max_freq_tweet = 'RT @zaynmalik: Big cover for @cosmopolitanuk ! Boys looking slick http://example.com/FcWA80HI';
if($splitlines[1] =~ /\Q$max_freq_tweet\E/){
    print FILE5 "$splitlines2[1] \n";
}

But it still doesn’t seem to be working.

  • 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-17T12:33:14+00:00Added an answer on June 17, 2026 at 12:33 pm

    Either escape the @ via a backslash, or use single quotes.

    my $search_string = 'RT @zaynmalik: Big cover for @cosmopolitanuk ! Boys looking slick http://example.com/FcWA80HI';
    # or:               "RT \@zaynmalik: Big cover for \@cosmopolitanuk ! Boys looking slick http://example.com/FcWA80HI"
    
    if (-1 != index $str, $search_string) { do something }
    

    If you have a string and want to use it in a regex, you should make sure to protect the meaning via \Q...\E:

    if ($str =~ /\Q$search_string\E/) { do something }
    

    This \QUOT\E doesn’t prevent array interpolation, but no character in that string will be considered special; without it the . in the string would match any character!

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

Sidebar

Related Questions

I'm facing problems with initializing a std::string variable using (i.e. an empty string). It's
Guyz facing problems with creating a push notification service (for android) using Google C2DM
I'm facing problems with the UTF-8 encoding on Heroku. I need to pass the
I am facing some problems for using placement new for contiguous memory.Please guide me,
I am facing problems while parsing RSS feeds from different sites. I need to
I am using cwac-endless adapter , and i am facing problems in disabling the
I'm using SHPAML (HAML for python) for Django, however, I'm facing problems converting SHPAML
I'm facing some problems using CDATA blocks inside h:outputscripts with MyFaces 2.0... but I
I want to create multiple children using fork() , but I am facing problems.
I'm facing problems using PieChart from the achartengine library. According to the demo, the

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.