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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:47:19+00:00 2026-05-16T23:47:19+00:00

Currently I am making a new module and I was wondering how could I

  • 0

Currently I am making a new module and I was wondering how could I implement in my module 2 things.

We often see the use like:

use My::Module qw(something);

for example:

use CGI::Carp qw(fatalsToBrowser);
  1. So the first question is, how do i
    retrieve this, i mean wether the
    user has specified anything and what
    he specified ?

  2. Second question is, How do i pass and read the args
    directly on the constructor like
    this:

    my $my_module = My::Module->new(arg1,arg2,arg3);

AS requested on the comment the simple module test code:

package My::Module;

# $Id$

use strict;
use Carp;

sub new {
        my $class = shift;
        my $self  = {};

        $self->{ARG1}         = undef;
        $self->{ARG2}         = undef;
        $self->{ARG3}         = undef;
        $self->{ARG4}         = undef;

        bless($self,$class);
        return $self;
}

sub arg1 {
        my $self = shift;
        if (@_) { $self->{ARG1} = shift }
        return $self->{ARG1};
}

sub arg2 {
        my $self = shift;
        if (@_) { $self->{ARG2} = shift }
        return $self->{ARG2};
}

sub arg3 {
        my $self = shift;
        if (@_) { $self->{ARG3} = shift }
        return $self->{ARG3};
}

sub arg4 {
        my $self = shift;
        if (@_) { $self->{ARG4} = shift }
        return $self->{ARG4};
}

sub dump {
        my $self = shift;

        require Data::Dumper;
        my $d = Data::Dumper->new([$self], [ref $self]);
        $d->Deepcopy(1);
        return $d->Dump();
}

1;  # so the require or use succeeds
  • 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-05-16T23:47:20+00:00Added an answer on May 16, 2026 at 11:47 pm

    import subroutine gets the arguments passed in a use. The following code samples should help you.

    File: My/Module.pm

    package My::Module;
    
    use warnings;
    use strict;
    
    use Data::Dumper;
    
    sub import {
        my ( $package, @args ) = @_;
    
        print Dumper \@args;
    }
    
    1;
    

    File: module.pl

    #!/usr/bin/env perl
    
    use warnings;
    use strict;
    
    use My::Module qw(something);
    

    If you are programming an object oriented module, you may try Moose which will save you lots of time.

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

Sidebar

Related Questions

I'm fairly new to python and I am currently making use of the numPy
I am currently building an making my new website. It uses one page and
I am new to Object Oriented PHP. Currently I am making a login script
I am currently making an app which works with images. I need to implement
I am making simple graphical game in WinForms and currently I would like to
I am very new to unit testing and writing/using exceptions. I am currently making
I'm currently making a small program to teach me some new Java, and I'm
I am a new android developer and I am currently making an application to
I am currently making a module, which does the hard work for you with
Greetings I'm currently making an application in WPF as I'm fairly new to WPF

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.