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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:10:23+00:00 2026-05-13T10:10:23+00:00

How do I find a literal % with the LIKE-operator? #!/usr/bin/perl use warnings; use

  • 0

How do I find a literal % with the LIKE-operator?

#!/usr/bin/perl
use warnings;
use strict;

use DBI;

my $table = 'formula';
my $dbh = DBI->connect ( "DBI:CSV:", undef, undef, { RaiseError => 1 } );

my $AoA = [ [ qw( id formula ) ], 
        [ 1, 'a + b' ], 
        [ 2, 'c - d' ], 
        [ 3, 'e * f' ], 
        [ 4, 'g / h' ], 
        [ 5, 'i % j' ],     ];

$dbh->do( qq{ CREATE TEMP TABLE $table AS IMPORT ( ? ) }, {}, $AoA ); 

my $sth = $dbh->prepare ( qq{ SELECT * FROM $table WHERE formula LIKE '%[%]%' } );
$sth->execute;
$sth->dump_results;

# Output:
# 3, 'e * f'
# 1 rows
  • 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-13T10:10:24+00:00Added an answer on May 13, 2026 at 10:10 am

    Looks like you can’t do this with current version of DBD::CSV.

    You are using DBD::CSVmodule to access data. It uses SQL::Statement module to handle expresions. I’ve searched its source code and found that following code handles LIKE sql statement condition:

    ## from SQL::Statement::Operation::Regexp::right method
    unless ( defined( $self->{PATTERNS}->{$right} ) )
    {
        $self->{PATTERNS}->{$right} = $right;
        ## looks like it doen't check any escape symbols
        $self->{PATTERNS}->{$right} =~ s/%/.*/g; 
        $self->{PATTERNS}->{$right} = $self->regexp( $self->{PATTERNS}->{$right} );
    }
    

    Look at $self->{PATTERNS}->{$right} =~ s/%/.*/g; line. It converts LIKE pattern to regexp. And it doesn’t do any check of any escape symbols. All % symbols are blindly translated to .* pattern. That’s why I think it’s not implemented yet.

    Well, may be someone’ll find time to fix this issue.

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

Sidebar

Related Questions

I've got a std::map: std::map<std::string, std::string> I'm passing string literal to find method. Obviously,
I have two methods in the same class and would like to find out
Possible Duplicate: Can you define “literal” tables in SQL? Occasionally I find myself in
I would like to add a literal dynamically on a page but right after
Given a filename like 'prefix.extension', I would like to find all files of the
I often find that attributes can be too large. Sometimes it feels like the
I'm referring to the %w operator/constructor/whatever you may call it, used like this: %w{
It seems like there was no such question here before. Where can I find
I am trying to find all occurrences of a literal float value in Python
In the quest for localization I need to find all the string literals littered

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.