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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:02:22+00:00 2026-06-12T10:02:22+00:00

I am new with Perl and learning it. I write a script which provides

  • 0

I am new with Perl and learning it. I write a script which provides word auto completion by tab as bash provides. If input is not in defined array, it prints predefined message and if input is in array then it run system command for the same.

It runs fine as per my assumptions but if I input only [ character, it gives errors which i can’t find that why it happens.

One more thing, suppose, I type only tab without any character, it does not shows predefined commands in array.It only prompt.

Kindly guide me and if I am wrong, please correct me.

Before I am using bash shell scripts in that we have -x option to debug while run time, is there any option with Perl to do that?

my script:

 #!/usr/bin/perl

 use Term::Complete;
 use List::Util 'first';

 @cmd = qw/ls uptime clear/;
 while (defined @cmd) {

     $in = Complete('prompt', @cmd);
     if (first { /$in/ } @cmd) {

         system($in);
     }
     elsif ($in eq 'exit') {

         `kill -9 $$`;
     }
     else {

         print "Use these commands: ls uptime clear";
    }
}

Error , if i enter [ :

perl tab1.pl 
prompt uptime
12:02:31 up  3:29,  2 users,  load average: 0.00, 0.00, 0.00
prompt [
Unmatched [ in regex; marked by <-- HERE in m/[ <-- HERE / at tab1.pl line 8.

BR
Ben

  • 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-12T10:02:23+00:00Added an answer on June 12, 2026 at 10:02 am

    [ is a special character in regex, you have to escape it.

    If you read the input from user, and want to search as is, you can use \Q and \E:

    /\Q$in\E/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to Bash scripting. I am trying to write a script
I am very new to Perl, and I am trying to write a word
I have started learning perl and like to try out new things. I have
Hi I am new to Perl an in a learning process. I am having
I'm having a very strange error. I run a perl script which executes linux
I'm very new to Perl and currently I'm learning it on Windows 7 with
The following Perl syntax replaces OLD with NEW, but not if a digit exists
I am a new guy learning perl and working as it goes. I am
I am learning Perl , very new user . May i know whats the
I'm still learning Perl and CLASS::DBI. I have a script that does a bunch

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.