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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:57:16+00:00 2026-06-12T01:57:16+00:00

How to make perl bytecode if sub is there in another file.pl so that

  • 0

How to make perl bytecode if sub is there in another file.pl so that I can get all perl script in to binary to give for usage but I am getting codedump warning.

Here is the example how I have done!

File: add.pl

require "util.pl";

$a = 1;

$b = 2;

$res = add($a,$b);

print $res;

File: util.pl

sub add()

{

my ($a,$b) = @_;


my $c = $a + $b;

return $c;

}

1; #to return true

Then when I run:

perlcc add.pl

./a.out

I get

Segmentation fault (core dumped)

I also tried

perlcc add.pl util.pl

but it says

/usr/bin/perlcc: using add.pl as input file, ignoring util.pl

Note:

If both are in single file

perlcc file.pl 

and

./a.out 

will work

  • 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-12T01:57:17+00:00Added an answer on June 12, 2026 at 1:57 am

    I cannot answer for the actual compiler problem, but let me make a few notes.

    <Edit> the more I look at this, the more I think that the problem is the namespacing of the add function. When they are in the same file, the function is declared in the main namespace. I think that would be true of the require-d file too, since there was not package declaration. Either way, these are still some good notes that I hope help. </Edit>

    1. You really should use strict and warnings pragmas
    2. You shouldn’t use $a and $b, because they are semi-magical in Perl and should be avoided (yeah, thats a weird one)
    3. Perl prototypes are not the same as most languages, and even then the empty prototype () on your add function is incorrect, best to leave it off

    Those things said here is how I would format my files.

    File: add.pl

    use strict;
    use warnings;
    
    use MyUtils;
    
    my $x = 1;
    
    my $y = 2;
    
    my $res = add($a,$b);
    
    print $res;
    

    File: MyUtils.pm

    package MyUtils;
    
    use strict;
    use warnings
    
    use parent 'Exporter';
    our @EXPORT = ('add');
    
    sub add
    
    {
    
    my ($x,$y) = @_;
    
    
    my $c = $x + $y;
    
    return $c;
    
    }
    
    1;
    

    This uses the more modern module/package formalism for reusable libraries. The use directive contains a require directive, but does it at compile-time rather than run-time.

    The Exporter module (and the @EXPORT variable) correctly import the function into the script’s namespace (typically main).

    Perhaps perlcc will like these changes better; but even if not, these are good practices to get used to.

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

Sidebar

Related Questions

Is there any single magic preamble that will make a Perl script run under
How can I make a HTTP PUT request in Perl that contains application/x-www-form-urlencoded data?
For an assignment in college, we have to make a script in Perl that
Possible Duplicate: How can I make an HTTP GET request from Perl? I am
I have the below Perl code to make a copy of a binary file
I can't seem to make Perl's flock work. I'm locking a file, checking return
Is there a way to make Perl's Template display warnings for all undefined values
I am trying to make a Master perl script calling children perl script and
I am trying to make an interactive shell script in Perl. The only user
How can I in perl make system(xcodebuild); only relay stderr, and not stdout. (xcodebuild

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.