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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:07:00+00:00 2026-06-17T17:07:00+00:00

I have a sort of perl terminal ( pastebin code ) we’ll call it

  • 0

I have a sort of perl “terminal” (pastebin code) we’ll call it that I’ve written, the idea behind writing it is I wanted to run perl code line by line, allowing me to run new commands on existing (large) data sets, without having to change a script and reload the data set and re-run my script.

(Mind you, I wrote this almost a year ago now, and it was mostly a learning experiment (with a dynamic function tablet), however now I have some use for it and discovered some issues which are preventing me from utilising it.)

As such, I eval user entered commands, however, they aren’t behaving as expected and perhaps someone can shed some light on why this would be.

This is the ‘important’ bit, I have the command line data stored in @args, and the first element of that is stored in $prog. I check if there’s an existing function (I allow users to create functions, and really abuse references to get an action table) if not I try and eval the command.

if(exists($actions{$prog})){
        print "\n";
        $actions{$prog}->(@args);
        print "\n";
}else{
        print "\nEVALing '$command'\n";
        eval $command;
        warn $@ if $@;
        print "\n";
}

As can be seen below, it works as expected for the assignment of scalars, but fails with the assignment of arrays and hashes.

user@host:~/$ perl term.pl 
1358811935>$a = 0;
EVALing '$a = 0;'

1358811937>print $a;
EVALing 'print $a;'
0
1358811944>@b = qw(2 3);                                                                                                      
EVALing '@b = qw(2 3);'
Global symbol "@b" requires explicit package name at (eval 5) line 1.

1358811945>print @b;
EVALing 'print @b;'
Global symbol "@b" requires explicit package name at (eval 6) line 1.

1358812008>my @b = qw(2 3);                                                                                                   
EVALing 'my @b = qw(2 3);'

1358812008>print "@b";
EVALing 'print "@b";'
Possible unintended interpolation of @b in string at (eval 9) line 1.
Global symbol "@b" requires explicit package name at (eval 9) line 1.

1358812016>print join(',',@b);                                                                                                
EVALing 'print join(',',@b);'
Global symbol "@b" requires explicit package name at (eval 10) line 1.

1358812018>
  • 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-17T17:07:01+00:00Added an answer on June 17, 2026 at 5:07 pm

    Variables $a and $b are special, because they are used by sort. Therefore, strict does not complain if they are not declared. Using $x would trigger the same error as arrays and hashes.

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

Sidebar

Related Questions

I have a Perl script using a system call to sort a tsv file:
I have written a perl code for processing file 'Output.txt' which has below Content.
In my perl progarm i have the following code: @alpha=('toM','jERRy','mickeY','MARio'); print sort{$a cmp $b}
I have a Perl program that I've written that parses SQL-like statements and creates
I have to sort out my data by some column, such that some specific
I have a perl array of to-do tasks that looks like this: @todos =
I have scripts that have one-liners or sort scripts from other languages within them.
I have a log file that looks like the following: 2010-05-12 12:23:45 Some sort
Here is the code, I know it is not perfect perl. If you have
Is there a way to do very quick sort in perl? Like I have

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.