Solved

Module definition problem

Posted on 2002-07-20
2
221 Views
Last Modified: 2010-03-05
I'm trying to define a module:

package Foo;

use strict;

require Exporter;

our @ISA = qw(Exporter);
our @EXPORT = qw(bar);
our $VERSION = "1.0";

sub bar() {
    my $val = shift;

    print $val;
}

1;

However when I try to use the bar function as follows:

use strict;

use lib 'E:/Programming/Perl/libs';
use Foo;

bar("Test");

I get the following error:

Too many arguments for Foo::bar at test.pl line 6, near ""Test")"
Execution of test.pl aborted due to compilation errors.

What's going on here?
0
Comment
Question by:derekl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 100 total points
ID: 7167243
You used the prototype bar() which means that bar has no arguments.
You probably wanted either

sub bar($) {
    my $val = shift;
    print $val;
}

or

sub bar {
    my $val = shift;
    print $val;
}
0
 

Author Comment

by:derekl
ID: 7167261
Thank I would have stared at that for 4 or 5 more hours before picking it up.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Perl 101 11 91
batch script for automated email 12 142
Union rows in array that have common elements 2 117
Ned Perl Snippet to Read Files in Directory 5 82
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question