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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:15:37+00:00 2026-06-10T12:15:37+00:00

I am unable to avoid the comment lines(lines starting with *) for parsing during

  • 0

I am unable to avoid the comment lines(lines starting with *) for parsing during string replacement in a file. Please help me with my code.

`perl -pi.bak -e "$_ =~/[#.*]*/; /s/PATTERN/REPLACEMENT STRING/g" Test.txt`;

Am using Perl in Eclipse,Windows XP.

I get the following Error message:

Number found where operator expected at -e line 6, near "*    LAST UPDATED 09/15"
(Might be a runaway multi-line // string starting on line 1)
(Missing operator before 15?)
Bareword found where operator expected at -e line 6, near "1994 AT"
(Missing operator before AT?)

Thanks in Advance,
Perl Newbie

  • 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-10T12:15:38+00:00Added an answer on June 10, 2026 at 12:15 pm

    use next to skip the following code if you match a comment:

    perl -i.back -p -e'next if /^#/; s/PATTERN/REPLACEMENT STRING/' Test.txt
    

    update: now as choroba suggested, instead of launching a separate instance of Perl and having to deal with quotes, you should probably have the whole thing in your main code:

    my $file= 'Test.txt';
    my $bak= "$file.bak";
    
    rename $file, $bak or die "cannot rename $file into $bak: $!";;
    
    open( my $in,  '<', $bak)  or die "cannot open $bak: $!";
    open( my $out, '>', $file) or die "cannot create $file: $!";
    
    while( <$in>)
      { if( ! /^\*/) # note the backslash here, * is a meta character
          { s/PERFORM \Q$func[5]\E\[\.\]*/# PERFORM $func[5]\.\n $hash{$func[5]}/g; }
        print {$out} $_;
      }
    close $in; 
    close $out;
    

    Note that $func[5] can (potentially) includes meta-characters, so I used \Q and \E to escape them.

    I am not sure about the \[\.\]* part, which as written matches a square bracket, a dot, and 0 or more closing square brackets: [., [.], or [.]]. I suspect that’s not what you want.

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

Sidebar

Related Questions

I am getting a Unable to load the requested file: default.php error in codeigniter
I am unable to get jasmine to load my custom javascript file, even though
Unable to cast object type System.Collections.Generic.List 1[NorthwindMVC3.Models.Product] to the type ofSystem.Collections.Generic.IEnumerator 1[NorthwindMVC3.Models.Product].\ public IEnumerator<Product>
Im unable to start new project in a virtualenv. This is what i did
Error: Unable to read data from the transport connection: A blocking operation was interrupted
I am unable to start the activity monitor on a different party app. When
I'm unable to execute the following prepared statement , PREPARE stmt FROM 'SELECT sb.id,sb.category,sb.make,sb.name,sb.pic,rs.slot
I'm getting an Unable to obtain public key for StrongNameKeyPair. exception using Newtonsoft's JsonConvert.SerializeObject
I am unable to change my max execution time. I have changed it in
I am unable to use the usual i18N localization of GWT to localize a

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.