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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:00:44+00:00 2026-06-10T21:00:44+00:00

I am trying to use perl to search and replace some outdated MySQL commands

  • 0

I am trying to use perl to search and replace some outdated MySQL commands

perl -i -pe 'BEGIN{undef $/;} s/if @RequestID.*@NextValue=@TableNameID output/if @RequestID is not NULL\n                begin\n                        select @TableNameID = @TableNameID + 1/smgi' $file1

However currently the file remains exactly the same before and after implying the regex isn’t matching?

I have the flags smgi turned on so .* also matches new lines taking advice from Multiline search replace with Perl

Here is a snip of the file I am trying to match

        if ( @@rowcount = 0 )
                return 1

        update Sequence set CurrentValue = @TableNameID where Code = 'TableName'
end

/* TableNames - Approval Request ID */
if @RequestID is not NULL
begin
        exec spGetNextSequence @Name='TableName', @NextValue=@TableNameID output

        insert into TableName        /* RequestID */
        (
                TableNameID,
                TxnVrsnID,
                FldNmCod,

If you test the pattern at http://regexpal.com/ (or any similar regex tester) – with smi on it matches fine?

Pattern: if @ApprovalRequestID.*@NextValue=@TxnDecoratorID output


This is the perl slightly split up so you can see what’s going on

perl -i -pe 'BEGIN{undef $/;} s/
if @RequestID.*@NextValue=@TableNameID output/
if @RequestID is not NULL\n
                begin\n
                        select @TableNameID = @TableNameID + 1
/smgi' $file1
  • 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-10T21:00:46+00:00Added an answer on June 10, 2026 at 9:00 pm

    @name is interpolated as a named Perl array inside of regular expression patterns. Escape the @ characters:

    perl -i -pe 'BEGIN{undef $/;} s/
    if \@RequestID.*\@NextValue=\@TableNameID output/
    if \@RequestID is not NULL\n
                    begin\n
                            select \@TableNameID = \@TableNameID + 1
    /smgi' $file1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use Perl to search through an html file, looking for
In perl I am trying to use a regex to search through specific hex
I am trying to use XML::RAI perl module on UTF8 coded text and I
Currently I am trying to use a bunch of custom perl modules, test.pm as
Im trying to extract part of a line with perl use strict; use warnings;
In a Perl daemon reacting to various events I'm trying to use a Null
I am trying to understand how to use instance variable in Perl OO -
I am trying to run a Perl file I created. use XML::XPath; use XML::XPath::XMLParser;
I am trying use gem tire to search in my application. I have tables
I'm trying to use a simple perl one-liner on the following input: @F7##########0/1 C4CTA6GCAAC56G67CTCA99C

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.